Search in sources :

Example 16 with MapLayer

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

the class ToolComposer method resetWindow.

public void resetWindow(String selectedArea) {
    try {
        hasCustomArea = !(selectedArea == null || selectedArea.trim().isEmpty());
        boolean ok = false;
        if (hasCustomArea) {
            MapLayer curTopArea;
            List<MapLayer> layers = getMapComposer().getPolygonLayers();
            if (layers != null && !layers.isEmpty()) {
                curTopArea = layers.get(0);
            } else {
                curTopArea = null;
            }
            if (curTopArea != prevTopArea) {
                if (isAreaHighlightTab()) {
                    loadAreaHighlightLayers(curTopArea.getDisplayName());
                } else if (isAreaTab()) {
                    //multiple areas can be defined
                    if (getFellowIfAny("cAreaCurrent") != null) {
                        loadAreaLayersCheckboxes(curTopArea.getDisplayName());
                    } else {
                        loadAreaLayers(curTopArea.getDisplayName());
                    }
                }
                ok = true;
            }
        }
        this.setTop(winTop);
        this.setLeft(winLeft);
        this.doModal();
        if (ok) {
            //not multiple areas can be defined
            if (getFellowIfAny("cAreaCurrent") == null) {
                onClick$btnOk(null);
            } else if (rAreaCustom != null) {
                rAreaCustom.setSelected(false);
            }
            hasCustomArea = false;
        }
        fixFocus();
    } catch (Exception ex) {
        LOGGER.error("Exception when resetting analysis window", ex);
    }
}
Also used : MapLayer(au.org.emii.portal.menu.MapLayer) IOException(java.io.IOException)

Example 17 with MapLayer

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

the class ToolComposer method loadSpeciesLayersBk.

public void loadSpeciesLayersBk() {
    try {
        List<MapLayer> layers = getMapComposer().getSpeciesLayers();
        int speciesLayersCount = 0;
        for (int i = 0; i < layers.size(); i++) {
            MapLayer lyr = layers.get(i);
            if (lyr.getSubType() != LayerUtilitiesImpl.SPECIES_UPLOAD) {
                speciesLayersCount++;
            }
            Radio rSp = new Radio(lyr.getDisplayName());
            rSp.setValue(lyr.getName());
            rSp.setId(lyr.getName().replaceAll(" ", "") + "__bk" + i);
            rgSpeciesBk.insertBefore(rSp, rSpeciesMappedBk);
        }
        if (speciesLayersCount > 1) {
            rSpeciesMappedBk.setLabel("All " + speciesLayersCount + StringConstants.SPECIES_CURRENTLY_MAPPED);
        } else {
            rSpeciesMappedBk.setVisible(false);
        }
        updateGeospatialKosherCheckboxesBk();
    } catch (Exception e) {
        LOGGER.error(StringConstants.UNABLE_TO_LOAD_LAYERS, e);
    }
}
Also used : MapLayer(au.org.emii.portal.menu.MapLayer) IOException(java.io.IOException)

Example 18 with MapLayer

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

the class ToolComposer method loadSpeciesLayers.

public void loadSpeciesLayers(boolean biocacheOnly, boolean checkboxes) {
    try {
        List<MapLayer> layers = getMapComposer().getSpeciesLayers();
        Radio selectedSpecies = null;
        String selectedSpeciesLayer = (String) params.get(StringConstants.SPECIES_LAYER_NAME);
        int speciesLayersCount = 0;
        for (int i = 0; i < layers.size(); i++) {
            MapLayer lyr = layers.get(i);
            if (biocacheOnly && lyr.getSpeciesQuery() != null && !(lyr.getSpeciesQuery() instanceof BiocacheQuery)) {
                continue;
            }
            if (lyr.getSubType() != LayerUtilitiesImpl.SPECIES_UPLOAD) {
                speciesLayersCount++;
            }
            if (!checkboxes) {
                Radio rSp = new Radio(lyr.getDisplayName());
                rSp.setValue(lyr.getName());
                rSp.setId(lyr.getName().replaceAll(" ", "") + "_" + i);
                rgSpecies.insertBefore(rSp, rSpeciesMapped);
                if (rSp.getValue().equals(selectedSpeciesLayer)) {
                    selectedSpecies = rSp;
                }
            } else {
                Checkbox rSp = new Checkbox(lyr.getDisplayName());
                rSp.setValue(lyr.getName());
                rSp.setId(lyr.getName().replaceAll(" ", "") + "_" + i);
                vboxSpecies.appendChild(rSp);
                if (vboxSpecies.getChildren().size() == 1) {
                    rSp.setChecked(true);
                }
            }
        }
        if (!checkboxes) {
            if (speciesLayersCount > 1) {
                rSpeciesMapped.setLabel("All " + speciesLayersCount + StringConstants.SPECIES_CURRENTLY_MAPPED);
            } else {
                rSpeciesMapped.setVisible(false);
            }
            if (selectedSpecies != null) {
                rgSpecies.setSelectedItem(selectedSpecies);
            } else if (StringConstants.NONE.equals(selectedSpeciesLayer)) {
                rgSpecies.setSelectedItem(rSpeciesAll);
            } else if (!layers.isEmpty()) {
                rgSpecies.setSelectedItem(rgSpecies.getItemAtIndex(1));
            } else {
                for (int i = 0; i < rgSpecies.getItemCount(); i++) {
                    if (rgSpecies.getItemAtIndex(i).isVisible() && rgSpecies.getItemAtIndex(i) != rSpeciesAll) {
                        rgSpecies.setSelectedItem(rgSpecies.getItemAtIndex(i));
                        break;
                    }
                }
            }
            updateGeospatialKosherCheckboxes();
        }
    } catch (Exception e) {
        LOGGER.error(StringConstants.UNABLE_TO_LOAD_LAYERS, e);
    }
}
Also used : MapLayer(au.org.emii.portal.menu.MapLayer) IOException(java.io.IOException)

Example 19 with MapLayer

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

the class AreaReportPDF method createSpeciesLayer.

MapLayer createSpeciesLayer(Query query, int red, int green, int blue, float opacity, boolean grid, int size, boolean uncertainty) {
    Color c = new Color(red, green, blue);
    String hexColour = Integer.toHexString(c.getRGB() & 0x00ffffff);
    String envString = "";
    if (grid) {
        //colour mode is in 'filter' but need to move it to envString
        envString += "colormode:grid";
    } else {
        envString = "color:" + hexColour;
    }
    envString += ";name:circle;size:" + size + ";opacity:1";
    if (uncertainty) {
        envString += ";uncertainty:1";
    }
    String uri = query.getUrl();
    uri += "service=WMS&version=1.1.0&request=GetMap&format=image/png";
    uri += "&layers=ALA:occurrences";
    uri += "&transparent=true";
    uri += (query.getQc() == null ? "" : query.getQc());
    uri += "&CQL_FILTER=";
    MapLayer ml = addWMSLayer("", "", uri + query.getQ(), opacity, null, null, LayerUtilitiesImpl.SPECIES, "", envString, query);
    ml.setDynamicStyle(true);
    ml.setEnvParams(envString);
    // for the sizechooser
    ml.setGeometryType(LayerUtilitiesImpl.POINT);
    ml.setBlueVal(blue);
    ml.setGreenVal(green);
    ml.setRedVal(red);
    ml.setSizeVal(3);
    ml.setOpacity(opacity);
    ml.setClustered(false);
    ml.setSpeciesQuery(query);
    return ml;
}
Also used : MapLayer(au.org.emii.portal.menu.MapLayer)

Example 20 with MapLayer

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

the class PortalSessionCloner method clone.

public PortalSession clone(PortalSession masterPortalSession) throws CloneNotSupportedException {
    PortalSession portalSession = (PortalSession) masterPortalSession.copy();
    /* super.clone will leave references to existing objects
         * in place, e.g.  portalSession.mapLayers == mapLayers is
         * currently true - to fix this, we will re-init all these
         * fields now
         *
         * although we don't mind sharing these between users, they
         * have to be defined 'later' when we call clone() because
         * the config file has not yet been loaded if we try earlier
         */
    portalSession.reset();
    // maplayers
    if (masterPortalSession.getMapLayers() != null) {
        for (MapLayer mapLayer : masterPortalSession.getMapLayers()) {
            portalSession.addMapLayer((MapLayer) mapLayer.clone());
        }
    }
    // default map bounding box
    if (masterPortalSession.getDefaultBoundingBox() != null) {
        portalSession.setDefaultBoundingbox((BoundingBox) masterPortalSession.getDefaultBoundingBox().copy());
    }
    // step 4: clone active layers
    if (masterPortalSession.getActiveLayers() != null) {
        for (MapLayer mapLayer : masterPortalSession.getActiveLayers()) {
            portalSession.getActiveLayers().add((MapLayer) mapLayer.clone());
        }
    }
    /* step 5: skip things
         *
         * o userDefined
         * o UserDefinedMenu
         * All get skipped because for new sessions they should
         * all be empty lists/objects
         */
    /* step 6: create an initial user defined menu tree - isn't done on creating
         * during stage 2 because otherwise we would have to bother cloning everything
         */
    LOGGER.debug("Session cloned");
    return portalSession;
}
Also used : PortalSession(au.org.emii.portal.session.PortalSession) MapLayer(au.org.emii.portal.menu.MapLayer)

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