Search in sources :

Example 31 with MapLayer

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

the class GDMComposer method loadMap.

public void loadMap(Event event) {
    String[] envlist = getSelectedLayersWithDisplayNames().split(":");
    for (String env2 : envlist) {
        String env = env2.split("\\|")[0];
        String displayName = env2.split("\\|")[1];
        String mapurl = CommonData.getGeoServer() + "/wms?service=WMS&version=1.1.0&request=GetMap&layers=ALA:gdm_" + env + "Tran_" + pid + "&styles=alastyles&FORMAT=image%2Fpng";
        String legendurl = CommonData.getGeoServer() + "/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&WIDTH=10&HEIGHT=1" + "&LAYER=ALA:gdm_" + env + "Tran_" + pid + "&STYLE=alastyles";
        LOGGER.debug(legendurl);
        String layername = "Tranformed " + displayName;
        getMapComposer().addWMSLayer(pid + "_" + env, layername, mapurl, (float) 0.5, null, legendurl, LayerUtilitiesImpl.GDM, null, null);
        MapLayer ml = getMapComposer().getMapLayer(pid + "_" + env);
        ml.setPid(pid + "_" + env);
        String infoUrl = CommonData.getSatServer() + "/output/gdm/" + pid + "/gdm.html";
        MapLayerMetadata md = ml.getMapLayerMetadata();
        md.setMoreInfo(infoUrl + "\nGDM Output\npid:" + pid);
        md.setId(Long.valueOf(pid));
    }
}
Also used : MapLayerMetadata(au.org.emii.portal.menu.MapLayerMetadata) MapLayer(au.org.emii.portal.menu.MapLayer)

Example 32 with MapLayer

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

the class MaxentComposer method loadMap.

public void loadMap(Event event) {
    String mapurl = CommonData.getGeoServer() + "/wms?service=WMS&version=1.1.0&request=GetMap&layers=ALA:species_" + pid + "&styles=alastyles&FORMAT=image%2Fpng";
    String legendurl = CommonData.getGeoServer() + "/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&WIDTH=10&HEIGHT=1" + "&LAYER=ALA:species_" + pid + "&STYLE=alastyles";
    LOGGER.debug(legendurl);
    //get job inputs
    String layername = tToolName.getValue();
    getMapComposer().addWMSLayer("species_" + pid, layername, mapurl, (float) 0.5, null, legendurl, LayerUtilitiesImpl.MAXENT, null, null);
    MapLayer ml = getMapComposer().getMapLayer("species_" + pid);
    ml.setPid(pid);
    String infoUrl = CommonData.getSatServer() + "/output/maxent/" + pid + "/species.html";
    MapLayerMetadata md = ml.getMapLayerMetadata();
    md.setMoreInfo(infoUrl + "\nMaxent Output\npid:" + pid);
    md.setId(Long.valueOf(pid));
    try {
        // set off the download as well
        String fileUrl = CommonData.getSatServer() + "/ws/download/" + pid;
        Filedownload.save(new URL(fileUrl).openStream(), "application/zip", tToolName.getValue().replaceAll(" ", "_") + ".zip");
    } catch (Exception e) {
        LOGGER.error("Error generating download for prediction model:", e);
    }
    this.detach();
}
Also used : MapLayerMetadata(au.org.emii.portal.menu.MapLayerMetadata) MapLayer(au.org.emii.portal.menu.MapLayer) URL(java.net.URL)

Example 33 with MapLayer

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

the class LayerLegendGeneralComposer method afterCompose.

@Override
public void afterCompose() {
    super.afterCompose();
    MapLayer llc2MapLayer = null;
    Map m = Executions.getCurrent().getArg();
    if (m != null) {
        for (Object o : m.entrySet()) {
            if (((Map.Entry) o).getKey() instanceof String && "map_layer".equals(((Map.Entry) o).getKey())) {
                llc2MapLayer = (MapLayer) ((Map.Entry) o).getValue();
            }
        }
    }
    cbColour.setSelectedIndex(0);
    getMapComposer().setFacetsOpenListener(new EventListener() {

        @Override
        public void onEvent(Event event) throws Exception {
            cbColour.open();
        }
    });
    getMapComposer().setLayerLegendNameRefresh(new EventListener() {

        @Override
        public void onEvent(Event event) throws Exception {
            txtLayerName.setValue((String) event.getData());
        }
    });
    init(llc2MapLayer, llc2MapLayer.getSpeciesQuery(), llc2MapLayer.getRedVal(), llc2MapLayer.getGreenVal(), llc2MapLayer.getBlueVal(), llc2MapLayer.getSizeVal(), (int) (llc2MapLayer.getOpacity() * 100), llc2MapLayer.getColourMode(), (StringConstants.GRID.equals(llc2MapLayer.getColourMode())) ? 0 : ((llc2MapLayer.isClustered()) ? 1 : 2), llc2MapLayer.getSizeUncertain());
    getFellow("btnSearch").addEventListener(StringConstants.ONCLICK, new EventListener() {

        @Override
        public void onEvent(Event event) throws Exception {
            List<String[]> legendLinesFiltered = new ArrayList<String[]>();
            String txt = ((Textbox) getFellow("txtSearch")).getValue().toLowerCase();
            if (txt.length() > 0) {
                Integer groupCount = mapLayer.getClassificationGroupCount();
                JSONArray groupObjects = mapLayer.getClassificationObjects();
                List<JSONObject> model = new ArrayList<JSONObject>();
                for (int i = 0; i < groupCount; i++) {
                    if (((JSONObject) groupObjects.get(i)).get("name").toString().toLowerCase().contains(txt)) {
                        model.add((JSONObject) groupObjects.get(i));
                    }
                }
                lbClassificationGroup.setModel(new SimpleListModel(model));
                lbClassificationGroup.setActivePage(0);
                ((Button) getFellow("btnClear")).setDisabled(false);
            }
        }
    });
    getFellow("btnClear").addEventListener(StringConstants.ONCLICK, new EventListener() {

        @Override
        public void onEvent(Event event) throws Exception {
            ((Textbox) getFellow("txtSearch")).setValue("");
            ((Button) getFellow("btnClear")).setDisabled(true);
            Integer groupCount = mapLayer.getClassificationGroupCount();
            JSONArray groupObjects = mapLayer.getClassificationObjects();
            List<JSONObject> model = new ArrayList<JSONObject>();
            for (int i = 0; i < groupCount; i++) {
                model.add((JSONObject) groupObjects.get(i));
            }
            lbClassificationGroup.setModel(new SimpleListModel(model));
            lbClassificationGroup.setActivePage(0);
        }
    });
}
Also used : MapLayer(au.org.emii.portal.menu.MapLayer) JSONArray(org.json.simple.JSONArray) ParseException(org.json.simple.parser.ParseException) JSONObject(org.json.simple.JSONObject) CheckEvent(org.zkoss.zk.ui.event.CheckEvent) Event(org.zkoss.zk.ui.event.Event) JSONObject(org.json.simple.JSONObject) LegendObject(au.org.ala.legend.LegendObject) List(java.util.List) EventListener(org.zkoss.zk.ui.event.EventListener)

Example 34 with MapLayer

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

the class LayerLegendGeneralComposer method onClick$btnApply.

public void onClick$btnApply(Event event) {
    MapComposer mc = getMapComposer();
    MapLayer ml = mapLayer;
    //layer on map settings
    if (getRed() != ml.getRedVal() || getGreen() != ml.getGreenVal() || getBlue() != ml.getBlueVal() || getSize() != ml.getSizeVal() || getOpacity() != (int) (ml.getOpacity() * 100) || (ml.getColourMode() != null && !ml.getColourMode().equals(getColourMode())) || (ml.isClustered() && getPointType() != 1) || ml.getSizeUncertain() != getUncertainty() || !ml.getDisplayName().equals(getDisplayName())) {
        //layer in menu settings
        if (!ml.getDisplayName().equals(getDisplayName())) {
            ml.setDisplayName(getDisplayName());
            //selection label
            mc.setLabelSelectedLayer(getDisplayName());
            mc.redrawLayersList();
        }
        ml.setRedVal(getRed());
        ml.setGreenVal(getGreen());
        ml.setBlueVal(getBlue());
        ml.setSizeVal(getSize());
        ml.setOpacity(getOpacity() / 100.0f);
        ml.setColourMode(getColourMode());
        ml.setClustered(getPointType() == 0);
        ml.setSizeUncertain(getUncertainty());
        mc.applyChange(ml);
    }
}
Also used : MapComposer(au.org.emii.portal.composer.MapComposer) MapLayer(au.org.emii.portal.menu.MapLayer)

Example 35 with MapLayer

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

the class MapComposer method getMapLayerWMS.

public Object getMapLayerWMS(String wmsurl) {
    // check if layer already present
    List udl = getPortalSession().getActiveLayers();
    Iterator iudl = udl.iterator();
    while (iudl.hasNext()) {
        MapLayer ml = (MapLayer) iudl.next();
        if (ml.getUri() != null && ml.getUri().equals(wmsurl)) {
            return ml;
        }
    }
    return null;
}
Also used : HasMapLayer(au.org.emii.portal.menu.HasMapLayer) MapLayer(au.org.emii.portal.menu.MapLayer) XmlArrayList(com.thoughtworks.xstream.persistence.XmlArrayList) List(java.util.List)

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