Search in sources :

Example 76 with MapLayer

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

Example 77 with MapLayer

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

the class AreaReportComposer method onFinish.

@Override
public boolean onFinish() {
    //close any existing area report
    Window w = (Window) getPage().getFellowIfAny("popupResults");
    if (w != null) {
        w.detach();
    }
    SelectedArea sa = getSelectedArea();
    String areaName = getSelectedAreaName();
    String areaDisplayName = getSelectedAreaDisplayName();
    boolean includeEndemic = getIsEndemic();
    MapLayer ml = getMapComposer().getMapLayer(areaName);
    double[] bbox = null;
    if (ml != null && ml.getMapLayerMetadata().getBbox() != null && ml.getMapLayerMetadata().getBbox().size() == 4) {
        bbox = new double[4];
        bbox[0] = ml.getMapLayerMetadata().getBbox().get(0);
        bbox[1] = ml.getMapLayerMetadata().getBbox().get(1);
        bbox[2] = ml.getMapLayerMetadata().getBbox().get(2);
        bbox[3] = ml.getMapLayerMetadata().getBbox().get(3);
    }
    AreaReportController.open(sa, areaName, areaDisplayName, (ml == null) ? null : ml.getAreaSqKm(), bbox, includeEndemic);
    detach();
    return true;
}
Also used : Window(org.zkoss.zul.Window) SelectedArea(au.org.emii.portal.menu.SelectedArea) MapLayer(au.org.emii.portal.menu.MapLayer)

Example 78 with MapLayer

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

the class ToolComposer method loadAreaLayersHighlight.

public void loadAreaLayersHighlight() {
    try {
        List<MapLayer> layers = getMapComposer().getPolygonLayers();
        for (int i = 0; i < layers.size(); i++) {
            MapLayer lyr = layers.get(i);
            Radio rAr = new Radio(lyr.getDisplayName());
            rAr.setId(lyr.getName().replaceAll(" ", "") + "_" + i);
            rAr.setValue(lyr.getName());
            rAr.setParent(rgAreaHighlight);
            rgAreaHighlight.insertBefore(rAr, rAreaCurrentHighlight);
        }
        rAreaNoneHighlight.setSelected(true);
    } catch (Exception e) {
        LOGGER.error(StringConstants.UNABLE_TO_LOAD_ACTIVE_AREA_LAYERS, e);
    }
}
Also used : MapLayer(au.org.emii.portal.menu.MapLayer) IOException(java.io.IOException)

Example 79 with MapLayer

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

the class ToolComposer method getSelectedArea.

public SelectedArea getSelectedArea() {
    String area = rAreaSelected.getValue();
    SelectedArea sa = null;
    try {
        if (StringConstants.CURRENT.equals(area)) {
            sa = new SelectedArea(null, getMapComposer().getViewArea());
        } else if (StringConstants.AUSTRALIA.equals(area)) {
            sa = new SelectedArea(null, CommonData.getSettings().getProperty(CommonData.AUSTRALIA_WKT));
        } else if (StringConstants.WORLD.equals(area)) {
            sa = new SelectedArea(null, CommonData.WORLD_WKT);
        } else {
            List<MapLayer> layers = getMapComposer().getPolygonLayers();
            for (MapLayer ml : layers) {
                if (area == null || area.equals(ml.getName())) {
                    sa = new SelectedArea(ml, null);
                    break;
                }
            }
        }
    } catch (Exception e) {
        LOGGER.warn("Unable to retrieve selected area", e);
    }
    return sa;
}
Also used : SelectedArea(au.org.emii.portal.menu.SelectedArea) MapLayer(au.org.emii.portal.menu.MapLayer) IOException(java.io.IOException)

Example 80 with MapLayer

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

the class ToolComposer method loadAreaHighlightLayers.

public void loadAreaHighlightLayers(String selectedAreaName) {
    try {
        // remove all radio buttons that don't have an id
        for (int i = rgAreaHighlight.getItemCount() - 1; i >= 0; i--) {
            String id = rgAreaHighlight.getItems().get(i).getId();
            if (id == null || id.length() == 0) {
                rgAreaHighlight.removeItemAt(i);
            } else {
                rgAreaHighlight.getItemAtIndex(i).setSelected(false);
            }
        }
        String selectedLayerName = (String) params.get(StringConstants.POLYGON_LAYER_NAME);
        Radio rSelectedLayer = null;
        List<MapLayer> layers = getMapComposer().getPolygonLayers();
        for (int i = 0; i < layers.size(); i++) {
            MapLayer lyr = layers.get(i);
            Radio rAr = new Radio(lyr.getDisplayName());
            rAr.setValue(lyr.getName());
            rAr.setParent(rgAreaHighlight);
            rgAreaHighlight.insertBefore(rAr, rAreaCurrentHighlight);
            if (lyr.getName().equals(selectedLayerName)) {
                rSelectedLayer = rAr;
            }
        }
        if (selectedAreaName != null && !selectedAreaName.isEmpty()) {
            for (int i = 0; i < rgAreaHighlight.getItemCount(); i++) {
                if (rgAreaHighlight.getItemAtIndex(i).isVisible() && rgAreaHighlight.getItemAtIndex(i).getLabel().equals(selectedAreaName)) {
                    rgAreaHighlight.setSelectedItem(rgAreaHighlight.getItemAtIndex(i));
                    break;
                }
            }
        } else if (rSelectedLayer != null) {
            rgAreaHighlight.setSelectedItem(rAreaSelected);
        } else if (StringConstants.NONE.equals(selectedLayerName)) {
            rgAreaHighlight.setSelectedItem(rAreaWorld);
        } else {
            for (int i = 0; i < rgAreaHighlight.getItemCount(); i++) {
                if (rgAreaHighlight.getItemAtIndex(i).isVisible()) {
                    rgAreaHighlight.setSelectedItem(rgAreaHighlight.getItemAtIndex(i));
                    break;
                }
            }
        }
        Clients.evalJavaScript("jq('#" + rgAreaHighlight.getSelectedItem().getUuid() + "-real').attr('checked', true);");
    } catch (Exception e) {
        LOGGER.error(StringConstants.UNABLE_TO_LOAD_ACTIVE_AREA_LAYERS, e);
    }
}
Also used : MapLayer(au.org.emii.portal.menu.MapLayer) IOException(java.io.IOException)

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