Search in sources :

Example 71 with MapLayer

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

the class MapComposer method setLayersVisible.

public void setLayersVisible(boolean show) {
    PortalSession portalSession = (PortalSession) Executions.getCurrent().getDesktop().getSession().getAttribute(StringConstants.PORTAL_SESSION);
    for (Listitem li : activeLayersList.getItems()) {
        if (li.getValue() == null || !"Map options".equals(((MapLayer) li.getValue()).getName())) {
            Checkbox cb = (Checkbox) li.getFirstChild().getFirstChild();
            if (show && !cb.isChecked()) {
                openLayersJavascript.execute(openLayersJavascript.getIFrameReferences() + openLayersJavascript.activateMapLayer((MapLayer) li.getValue(), false, true) + openLayersJavascript.updateMapLayerIndexes(portalSession.getActiveLayers()));
            } else if (!show && cb.isChecked()) {
                openLayersJavascript.removeMapLayerNow((MapLayer) li.getValue());
            }
            cb.setChecked(show);
            cb.setTooltiptext(show ? "Hide" : "Show");
        }
    }
    refreshContextualMenu();
}
Also used : Checkbox(org.zkoss.zul.Checkbox) PortalSession(au.org.emii.portal.session.PortalSession) HasMapLayer(au.org.emii.portal.menu.HasMapLayer) MapLayer(au.org.emii.portal.menu.MapLayer)

Example 72 with MapLayer

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

the class MapComposer method replaceWKTwithWMS.

public void replaceWKTwithWMS(MapLayer ml) {
    //don't replace if it has a facet or is mapped with WMS or is WKT ENVELOPE
    if (ml.getFacets() != null || ml.getWKT() == null || ml.getWKT().startsWith(StringConstants.ENVELOPE) || ml.getUri() != null) {
        return;
    }
    //only replace if WKT upload is successful
    String pid = UserShapes.upload(ml.getWKT(), ml.getDisplayName(), ml.getDescription(), Util.getUserEmail(), CommonData.getSettings().getProperty("api_key"));
    if (pid != null) {
        //2. remove old layer
        deactiveLayer(ml, true, false);
        //1. create new layer
        MapLayer newml = addObjectByPid(pid, ml.getDisplayName(), 1);
        newml.setMapLayerMetadata(ml.getMapLayerMetadata());
        newml.setAreaSqKm(ml.getAreaSqKm());
        newml.setUserDefinedLayer(ml.isUserDefinedLayer());
        newml.setDescription(ml.getDescription());
        newml.setWKT(ml.getWKT());
    }
}
Also used : HasMapLayer(au.org.emii.portal.menu.HasMapLayer) MapLayer(au.org.emii.portal.menu.MapLayer)

Example 73 with MapLayer

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

the class ToolComposer method getSelectedSpeciesBk.

public Query getSelectedSpeciesBk(boolean mapspecies, boolean applycheckboxes) {
    Query q = null;
    if (rgSpeciesBk == null) {
        return q;
    }
    Radio r = rgSpeciesBk.getSelectedItem();
    if (r == null) {
        if (rgSpeciesBk.getItemCount() == 0) {
            return q;
        }
        LOGGER.error("rgSpeciesBk item is not selected. step=" + currentStep + " method=" + getTitle() + " rgSpeces item at [0]=" + (rgSpeciesBk != null && rgSpeciesBk.getItemCount() > 0 ? rgSpeciesBk.getItemAtIndex(0).getValue() : "null or no species items in list"));
        r = rgSpeciesBk.getItemAtIndex(0);
    }
    String species = r.getValue();
    String id = rgSpeciesBk.getSelectedItem().getId();
    MapLayer ml = getMapComposer().getMapLayer(species);
    if (ml != null) {
        q = ml.getSpeciesQuery();
        if (q instanceof BiocacheQuery) {
            BiocacheQuery bq = (BiocacheQuery) q;
            q = bq.newFacetGeospatialKosher(applycheckboxes ? getGeospatialKosherBk() : null, false);
        }
    } else {
        try {
            if ("allspecies".equals(species)) {
                q = new BiocacheQuery(null, null, null, null, false, applycheckboxes ? getGeospatialKosherBk() : null);
            } else if ("allmapped".equals(species)) {
                throw new UnsupportedOperationException("Not yet implemented");
            } else if (StringConstants.MULTIPLE.equals(species)) {
                String lsids = getMultipleLsidsBk();
                if (lsids != null && lsids.length() > 0) {
                    q = new BiocacheQuery(lsids, null, null, null, false, applycheckboxes ? getGeospatialKosherBk() : null);
                }
            } else if ("uploadLsid".equals(species)) {
                //get the query from species list list
                SpeciesListListbox lb = id.endsWith("Bk") ? speciesListListboxBk : speciesListListbox;
                q = lb.extractQueryFromSelectedLists(applycheckboxes ? getGeospatialKosher() : null);
            } else if ((StringConstants.SEARCH.equals(species) || StringConstants.UPLOAD_SPECIES.equals(species)) && bgSearchSpeciesACComp.hasValidItemSelected()) {
                q = bgSearchSpeciesACComp.getQuery((Map) getMapComposer().getSession().getAttribute(StringConstants.USERPOINTS), false, applycheckboxes ? getGeospatialKosherBk() : null);
            }
        } catch (Exception e) {
            LOGGER.warn("Unable to retrieve selected species", e);
        }
    }
    return q;
}
Also used : SpeciesListListbox(au.org.ala.spatial.composer.species.SpeciesListListbox) MapLayer(au.org.emii.portal.menu.MapLayer) IOException(java.io.IOException)

Example 74 with MapLayer

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

the class ToolComposer method loadAreaLayersCheckboxes.

public void loadAreaLayersCheckboxes(String selectedAreaName) {
    try {
        List<MapLayer> layers = getMapComposer().getPolygonLayers();
        for (int i = 0; i < layers.size(); i++) {
            MapLayer lyr = layers.get(i);
            //add only if missing
            boolean found = false;
            if (getFellow("vboxArea") != null) {
                List checkboxes = getFellow("vboxArea").getChildren();
                for (int j = 0; j < checkboxes.size(); j++) {
                    if (checkboxes.get(j) instanceof Checkbox && ((Checkbox) checkboxes.get(j)).getLabel().equals(lyr.getDisplayName())) {
                        found = true;
                        break;
                    }
                }
            }
            if (!found) {
                Checkbox rAr = new Checkbox(lyr.getDisplayName());
                rAr.setValue(lyr.getName());
                if (lyr.getDisplayName().equals(selectedAreaName)) {
                    rAr.setChecked(true);
                }
                rAr.setParent(vboxArea);
                vboxArea.insertBefore(rAr, cAreaCurrent);
            }
        }
    } catch (Exception e) {
        LOGGER.error(StringConstants.UNABLE_TO_LOAD_ACTIVE_AREA_LAYERS, e);
    }
}
Also used : MapLayer(au.org.emii.portal.menu.MapLayer) EnvironmentalList(au.org.ala.spatial.composer.layer.EnvironmentalList) IOException(java.io.IOException)

Example 75 with MapLayer

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

the class ToolComposer method getAllSelectedSpecies.

public List<Query> getAllSelectedSpecies() {
    List<Query> selected = new ArrayList<Query>();
    for (Object species : vboxSpecies.getChildren()) {
        Checkbox chk = (Checkbox) species;
        if (chk.isChecked()) {
            MapLayer ml = getMapComposer().getMapLayer(chk.getValue().toString());
            if (ml != null) {
                Query q = ml.getSpeciesQuery();
                q.setName(ml.getDisplayName());
                selected.add(q);
            }
        }
    }
    return selected;
}
Also used : MapLayer(au.org.emii.portal.menu.MapLayer) JSONObject(org.json.simple.JSONObject)

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