Search in sources :

Example 41 with MapLayer

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

the class LayerLegendScatterplotController method updateCbHighlightArea.

private void updateCbHighlightArea() {
    for (int i = cbHighlightArea.getItemCount() - 1; i >= 0; i--) {
        cbHighlightArea.removeItemAt(i);
    }
    boolean selectionSuccessful = false;
    for (MapLayer ml : getMapComposer().getPolygonLayers()) {
        Comboitem ci = new Comboitem(ml.getDisplayName());
        ci.setValue(ml);
        ci.setParent(cbHighlightArea);
        if (data != null && data.getHighlightSa() != null && data.getHighlightSa().getMapLayer().getName().equals(ml.getName())) {
            cbHighlightArea.setSelectedItem(ci);
            selectionSuccessful = true;
        }
    }
    //this may be a deleted layer or current view or au or world
    if (!selectionSuccessful && data != null && data.getHighlightSa() != null) {
        MapLayer ml = data.getHighlightSa().getMapLayer();
        if (ml != null) {
            Comboitem ci = new Comboitem(ml.getDisplayName() + " (DELETED LAYER)");
            ci.setValue(ml);
            ci.setParent(cbHighlightArea);
            cbHighlightArea.setSelectedItem(ci);
        } else {
            String name = "Previous area";
            if (data.getHighlightSa().getWkt() != null) {
                if (data.getHighlightSa().getWkt().equals(CommonData.getSettings().getProperty(CommonData.AUSTRALIA_WKT))) {
                    name = CommonData.getSettings().getProperty(CommonData.AUSTRALIA_NAME);
                } else if (data.getHighlightSa().getWkt().equals(CommonData.WORLD_WKT)) {
                    name = "World";
                }
            }
            Comboitem ci = new Comboitem(name);
            ci.setValue(data.getHighlightSa().getWkt());
            ci.setParent(cbHighlightArea);
            cbHighlightArea.setSelectedItem(ci);
        }
    }
}
Also used : HasMapLayer(au.org.emii.portal.menu.HasMapLayer) MapLayer(au.org.emii.portal.menu.MapLayer)

Example 42 with MapLayer

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

the class MapComposer method addPointsOfInterestLayer.

public MapLayer addPointsOfInterestLayer(String wkt, String label, String displayName) {
    MapLayer mapLayer = null;
    if (safeToPerformMapAction()) {
        if (portalSessionUtilities.getUserDefinedById(getPortalSession(), label) == null) {
            mapLayer = remoteMap.createWKTLayer(wkt, label);
            mapLayer.setDisplayName(displayName);
            mapLayer.setPointsOfInterestWS(CommonData.getLayersServer() + "/intersect/poi/wkt");
            mapLayer.setOpacity((float) 0.4);
            mapLayer.setDynamicStyle(true);
            activateLayer(mapLayer, true, true);
        } else {
            // fail
            showMessage("WKT layer already exists");
            LOGGER.debug("refusing to add a new layer with name " + label + " because it already exists in the menu");
        }
    }
    return mapLayer;
}
Also used : HasMapLayer(au.org.emii.portal.menu.HasMapLayer) MapLayer(au.org.emii.portal.menu.MapLayer)

Example 43 with MapLayer

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

the class MapComposer method deactiveLayer.

public void deactiveLayer(MapLayer itemToRemove, boolean updateMapAndLayerControls, boolean recursive, boolean updateOnly) {
    if (itemToRemove != null) {
        Query q = itemToRemove.getSpeciesQuery();
        if (q instanceof UserDataQuery) {
            String pid = q.getQ();
            Map<String, UserDataDTO> htUserSpecies = (Map) getMapComposer().getSession().getAttribute(StringConstants.USERPOINTS);
            if (htUserSpecies != null) {
                htUserSpecies.remove(pid);
            }
        }
        // update the active layers list
        List<MapLayer> activeLayers = getPortalSession().getActiveLayers();
        if (activeLayers != null) {
            LOGGER.debug("obtained activelayers arraylist from session, count: " + activeLayers.size());
            if (!activeLayers.isEmpty()) {
                ListModelList listmodel = (ListModelList) activeLayersList.getModel();
                if (listmodel != null) {
                    listmodel.remove(itemToRemove);
                    if (activeLayers.isEmpty()) {
                        lblSelectedLayer.setValue("No layers added");
                    }
                }
            } else {
                LOGGER.debug("active layers list is empty, so not updating it");
            }
        }
        if (updateMapAndLayerControls) {
            if (!updateOnly) {
                // tell openlayers to kill the layer
                openLayersJavascript.removeMapLayerNow(itemToRemove);
            }
            updateLayerControls();
            removeFromSession(itemToRemove.getName());
        }
        // descend children if we were called recursively
        if (recursive && itemToRemove.hasChildren()) {
            for (MapLayer child : itemToRemove.getChildren()) {
                deactiveLayer(child, updateMapAndLayerControls, true);
            }
        }
    }
    refreshContextualMenu();
}
Also used : HasMapLayer(au.org.emii.portal.menu.HasMapLayer) MapLayer(au.org.emii.portal.menu.MapLayer) UserDataDTO(au.org.ala.spatial.dto.UserDataDTO) RemoteMap(au.org.emii.portal.util.RemoteMap)

Example 44 with MapLayer

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

the class MapComposer method load.

/**
     * Initial building of the tree menu and active layers list based on the
     * values obtained from the current session.
     * <p/>
     * JavaScript for loading default map layers and setting the default zoombox
     * is in SessionInit.java
     */
public void load() {
    LOGGER.debug("entering loadMapLayers");
    PortalSession portalSession = getPortalSession();
    List<MapLayer> activeLayers = portalSession.getActiveLayers();
    // model and renderer for active layers list
    ListModelList activeLayerModel = new ListModelList(activeLayers, true);
    // tell the list about them...
    if (activeLayers.isEmpty()) {
        MapLayer ml = remoteMap.createLocalLayer(LayerUtilitiesImpl.MAP, "Map options");
        ml.setRemoveable(false);
        activeLayers.add(ml);
    }
    activeLayersList.setModel(activeLayerModel);
    activeLayersList.setItemRenderer(activeLayerRenderer);
    activeLayersList.setSelectedIndex(activeLayerModel.size() - 1);
    updateLayerControls();
    refreshContextualMenu();
}
Also used : PortalSession(au.org.emii.portal.session.PortalSession) HasMapLayer(au.org.emii.portal.menu.HasMapLayer) MapLayer(au.org.emii.portal.menu.MapLayer)

Example 45 with MapLayer

use of au.org.emii.portal.menu.MapLayer 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)

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