Search in sources :

Example 1 with MapLayerMetadata

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

the class MapComposer method mapSpeciesFilter.

MapLayer mapSpeciesFilter(Query q, String species, String rank, int count, int subType, String wkt, boolean grid, int size, float opacity, int colour, boolean mapExpertDistributions) {
    String filter = q.getQ();
    //just in case it fails
    if (mapExpertDistributions) {
        try {
            if (q instanceof BiocacheQuery) {
                String lsids = ((BiocacheQuery) q).getLsids();
                List<String> extraLsids = ((BiocacheQuery) q).getLsidFromExtraParams();
                if (lsids != null && lsids.length() > 0) {
                    loadDistributionMap(lsids, wkt);
                }
                for (String extraLsid : extraLsids) {
                    if (extraLsid != null && extraLsid.length() > 0) {
                        LOGGER.debug("loading layer for: " + extraLsid);
                        loadDistributionMap(extraLsid, wkt);
                    }
                }
            }
        } catch (Exception e) {
            LOGGER.error("failed to map species distribution areas", e);
        }
    }
    MapLayer ml = mapSpeciesWMSByFilter(getNextAreaLayerName(species), filter, subType, q, grid, size, opacity, colour);
    if (ml != null) {
        addToSession(ml.getName(), filter);
        MapLayerMetadata md = ml.getMapLayerMetadata();
        md.setOccurrencesCount(count);
        ml.setClustered(false);
        if (grid) {
            ml.setColourMode(StringConstants.GRID);
        }
        addLsidBoundingBoxToMetadata(md, q);
    }
    return ml;
}
Also used : MapLayerMetadata(au.org.emii.portal.menu.MapLayerMetadata) HasMapLayer(au.org.emii.portal.menu.HasMapLayer) MapLayer(au.org.emii.portal.menu.MapLayer) ParseException(org.json.simple.parser.ParseException)

Example 2 with MapLayerMetadata

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

the class ALOCComposer method loadMap.

public void loadMap(Event event) {
    //get job inputs
    try {
        for (String s : getJob().split(";")) {
            if (s.startsWith("gc")) {
                layerLabel = tToolName.getValue();
                generationCount++;
                break;
            }
        }
    } catch (Exception e) {
        LOGGER.error("error getting ALOC job info", e);
    }
    if (layerLabel == null) {
        layerLabel = "My Classification " + generationCount;
        generationCount++;
    }
    String mapurl = CommonData.getGeoServer() + "/wms?service=WMS&version=1.1.0&request=GetMap&layers=ALA:aloc_" + pid + "&FORMAT=image%2Fpng";
    String legendurl = CommonData.getGeoServer() + "/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&WIDTH=10&HEIGHT=1" + "&LAYER=ALA:aloc_" + pid;
    LOGGER.debug(legendurl);
    legendPath = legendurl;
    getMapComposer().addWMSLayer("aloc_" + pid, layerLabel, mapurl, (float) 0.5, null, legendurl, LayerUtilitiesImpl.ALOC, null, null);
    MapLayer mapLayer = getMapComposer().getMapLayer("aloc_" + pid);
    if (mapLayer != null) {
        mapLayer.setPid(pid);
        WMSStyle style = new WMSStyle();
        style.setName(StringConstants.DEFAULT);
        style.setDescription("Default style");
        style.setTitle(StringConstants.DEFAULT);
        style.setLegendUri(legendurl);
        LOGGER.debug("legend:" + legendPath);
        mapLayer.addStyle(style);
        mapLayer.setSelectedStyleIndex(1);
        MapLayerMetadata md = mapLayer.getMapLayerMetadata();
        String infoUrl = CommonData.getSatServer() + "/output/aloc/" + pid + "/classification.html" + "\nClassification output\npid:" + pid;
        md.setMoreInfo(infoUrl);
        md.setId(Long.valueOf(pid));
        getMapComposer().updateLayerControls();
        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 ex) {
            LOGGER.error("Error generating download for classification model:", ex);
        }
    }
    this.detach();
}
Also used : MapLayerMetadata(au.org.emii.portal.menu.MapLayerMetadata) WMSStyle(au.org.emii.portal.wms.WMSStyle) MapLayer(au.org.emii.portal.menu.MapLayer) URL(java.net.URL)

Example 3 with MapLayerMetadata

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

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

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

the class SitesBySpeciesComposer method loadLayer.

void loadLayer(String type, String name, int typeId) {
    String mapurl = CommonData.getGeoServer() + "/wms?service=WMS&version=1.1.0&request=GetMap&layers=ALA:" + type + "_" + pid + "&style=" + type + "_" + pid + "&FORMAT=image%2Fpng";
    String legendurl = CommonData.getGeoServer() + "/wms?REQUEST=GetLegendGraphic&VERSION=1.0.0&FORMAT=image/png&WIDTH=10&HEIGHT=1" + "&LAYER=ALA:" + type + "_" + pid + "&STYLE=" + type + "_" + pid;
    LOGGER.debug(legendurl);
    String layername = getMapComposer().getNextAreaLayerName(name);
    getMapComposer().addWMSLayer(pid + "_" + type, layername, mapurl, (float) 0.5, null, legendurl, typeId, null, null);
    MapLayer ml = getMapComposer().getMapLayer(pid + "_" + type);
    ml.setPid(pid + "_" + type);
    String infoUrl = CommonData.getSatServer() + "/output/sitesbyspecies/" + pid + "/" + type + "_metadata.html";
    MapLayerMetadata md = ml.getMapLayerMetadata();
    md.setMoreInfo(infoUrl + "\n" + name + "\npid:" + pid);
    md.setId(Long.valueOf(pid));
}
Also used : MapLayerMetadata(au.org.emii.portal.menu.MapLayerMetadata) MapLayer(au.org.emii.portal.menu.MapLayer)

Aggregations

MapLayerMetadata (au.org.emii.portal.menu.MapLayerMetadata)16 MapLayer (au.org.emii.portal.menu.MapLayer)15 URL (java.net.URL)7 ParseException (org.json.simple.parser.ParseException)5 JSONObject (org.json.simple.JSONObject)4 JSONParser (org.json.simple.parser.JSONParser)4 Facet (au.org.ala.legend.Facet)3 HasMapLayer (au.org.emii.portal.menu.HasMapLayer)2 WMSStyle (au.org.emii.portal.wms.WMSStyle)2 XmlArrayList (com.thoughtworks.xstream.persistence.XmlArrayList)2 LegendObject (au.org.ala.legend.LegendObject)1 CRSEnvelope (org.geotools.data.ows.CRSEnvelope)1 Layer (org.geotools.data.ows.Layer)1 WebMapServer (org.geotools.data.wms.WebMapServer)1 GetMapRequest (org.geotools.data.wms.request.GetMapRequest)1 MetadataURL (org.geotools.data.wms.xml.MetadataURL)1 JSONArray (org.json.simple.JSONArray)1