Search in sources :

Example 26 with MapComposer

use of au.org.emii.portal.composer.MapComposer in project spatial-portal by AtlasOfLivingAustralia.

the class AreaWKT method onClick$btnCancel.

public void onClick$btnCancel(Event event) {
    MapComposer mc = getMapComposer();
    if (layerName != null && mc.getMapLayer(layerName) != null) {
        mc.removeLayer(layerName);
    }
    this.detach();
}
Also used : MapComposer(au.org.emii.portal.composer.MapComposer)

Example 27 with MapComposer

use of au.org.emii.portal.composer.MapComposer in project spatial-portal by AtlasOfLivingAustralia.

the class AreaWKT method onClick$btnOk.

public void onClick$btnOk(Event event) {
    String wkt = displayGeom.getText();
    if (validWKT(wkt)) {
        MapComposer mc = getMapComposer();
        layerName = (mc.getMapLayer(txtLayerName.getValue()) == null) ? txtLayerName.getValue() : mc.getNextAreaLayerName(txtLayerName.getValue());
        MapLayer mapLayer = mc.addWKTLayer(wkt, layerName, txtLayerName.getValue());
        DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(System.currentTimeMillis());
        String metadata = "";
        metadata += "User pasted WKT \n";
        metadata += "Name: " + layerName + "<br />";
        metadata += "Date: " + formatter.format(calendar.getTime());
        mapLayer.getMapLayerMetadata().setMoreInfo(metadata);
        //reapply layer name
        getMapComposer().getMapLayer(layerName).setDisplayName(txtLayerName.getValue());
        getMapComposer().redrawLayersList();
        ok = true;
        this.detach();
    } else {
        invalidWKT.setVisible(true);
    }
}
Also used : MapComposer(au.org.emii.portal.composer.MapComposer) MapLayer(au.org.emii.portal.menu.MapLayer) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) Calendar(java.util.Calendar) SimpleDateFormat(java.text.SimpleDateFormat)

Example 28 with MapComposer

use of au.org.emii.portal.composer.MapComposer in project spatial-portal by AtlasOfLivingAustralia.

the class AreaWKT method onClick$btnClear.

public void onClick$btnClear(Event event) {
    MapComposer mc = getMapComposer();
    if (layerName != null && mc.getMapLayer(layerName) != null) {
        mc.removeLayer(layerName);
    }
    String script = mc.getOpenLayersJavascript().addBoxDrawingTool();
    mc.getOpenLayersJavascript().execute(mc.getOpenLayersJavascript().getIFrameReferences() + script);
    displayGeom.setValue("");
    invalidWKT.setVisible(false);
}
Also used : MapComposer(au.org.emii.portal.composer.MapComposer)

Example 29 with MapComposer

use of au.org.emii.portal.composer.MapComposer in project spatial-portal by AtlasOfLivingAustralia.

the class AreaMapPolygon method onClick$btnClear.

public void onClick$btnClear(Event event) {
    MapComposer mc = getMapComposer();
    if (layerName != null && mc.getMapLayer(layerName) != null) {
        mc.removeLayer(layerName);
    }
    String script = mc.getOpenLayersJavascript().addFeatureSelectionTool();
    mc.getOpenLayersJavascript().execute(mc.getOpenLayersJavascript().getIFrameReferences() + script);
    displayGeom.setValue("");
    btnOk.setDisabled(true);
    btnClear.setDisabled(true);
}
Also used : MapComposer(au.org.emii.portal.composer.MapComposer)

Example 30 with MapComposer

use of au.org.emii.portal.composer.MapComposer in project spatial-portal by AtlasOfLivingAustralia.

the class AreaMerge method mergeAreas.

void mergeAreas() {
    List<Facet> facets = new ArrayList<Facet>();
    List<Geometry> wkt = new ArrayList<Geometry>();
    WKTReader wktReader = new WKTReader();
    String layerDisplayNames = "";
    for (int i = 0; i < vboxAreas.getChildren().size(); i++) {
        Checkbox cb = (Checkbox) vboxAreas.getChildren().get(i);
        if (cb.isChecked()) {
            MapLayer ml = cb.getValue();
            if (layerDisplayNames.length() > 0) {
                layerDisplayNames += ", ";
            }
            layerDisplayNames += ml.getDisplayName();
            if (ml != null) {
                if (ml.getFacets() != null) {
                    facets.addAll(ml.getFacets());
                }
                try {
                    //get actual WKT when 'envelope' is specified
                    String w = ml.getWKT();
                    if (w.startsWith(StringConstants.ENVELOPE)) {
                        //should only be one pid
                        String pid = w.substring(w.indexOf(',') + 1, w.length() - 1);
                        w = Util.readUrl(CommonData.getLayersServer() + "/shape/wkt/" + pid);
                    }
                    Geometry g = wktReader.read(w);
                    if (g != null) {
                        wkt.add(g);
                    }
                } catch (ParseException e) {
                    LOGGER.error("cannot parse WKT for map layer: " + ml.getDisplayName() + " for WKT: " + ml.getWKT());
                }
            } else {
                String swkt = null;
                if (CommonData.getSettings().getProperty(CommonData.AUSTRALIA_NAME).equalsIgnoreCase(cb.getLabel())) {
                    swkt = CommonData.getSettings().getProperty(CommonData.AUSTRALIA_WKT);
                } else if ("Current Extent".equalsIgnoreCase(cb.getLabel())) {
                    swkt = getMapComposer().getViewArea();
                } else {
                    LOGGER.error("cannot determine what this checked area is: " + cb.getLabel());
                }
                if (swkt != null) {
                    try {
                        Geometry g = wktReader.read(swkt);
                        if (g != null) {
                            wkt.add(g);
                        }
                    } catch (ParseException e) {
                        LOGGER.error("cannot parse WKT for map layer: " + ml.getDisplayName() + " for WKT: " + swkt);
                    }
                }
            }
        }
    }
    //produce single geometry
    Geometry geometry = null;
    if (!wkt.isEmpty()) {
        geometry = wkt.get(0);
        for (int i = 1; i < wkt.size(); i++) {
            geometry = GeometryCombiner.combine(geometry, wkt.get(i));
        }
    }
    String finalWkt = (geometry == null) ? null : geometry.toString();
    MapComposer mc = getMapComposer();
    layerName = (mc.getMapLayer(txtLayerName.getValue()) == null) ? txtLayerName.getValue() : mc.getNextAreaLayerName(txtLayerName.getValue());
    MapLayer mapLayer = mc.addWKTLayer(finalWkt, layerName, txtLayerName.getValue());
    //if possible, use facets instead of WKT with biocache
    if (wkt.size() == facets.size()) {
        //change to a single OR facet.
        //Because all facet areas are single or multiple, ORs just need to OR for joining.
        String fq = facets.get(0).toString();
        for (int i = 1; i < facets.size(); i++) {
            fq += " OR " + facets.get(i).toString();
        }
        List<Facet> array = new ArrayList<Facet>();
        array.add(Facet.parseFacet(fq));
        mapLayer.setFacets(array);
    }
    DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
    java.util.Calendar calendar = java.util.Calendar.getInstance();
    calendar.setTimeInMillis(System.currentTimeMillis());
    String metadata = "";
    metadata += "Merged WKT layers\nLayers: " + layerDisplayNames + "\n";
    metadata += "Name: " + layerName + " <br />\n";
    metadata += "Date: " + formatter.format(calendar.getTime()) + " <br />\n";
    mapLayer.getMapLayerMetadata().setMoreInfo(metadata);
    //reapply layer name
    getMapComposer().getMapLayer(layerName).setDisplayName(txtLayerName.getValue());
    getMapComposer().redrawLayersList();
    ok = true;
    this.detach();
}
Also used : MapLayer(au.org.emii.portal.menu.MapLayer) ArrayList(java.util.ArrayList) WKTReader(com.vividsolutions.jts.io.WKTReader) Geometry(com.vividsolutions.jts.geom.Geometry) MapComposer(au.org.emii.portal.composer.MapComposer) Checkbox(org.zkoss.zul.Checkbox) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) ParseException(com.vividsolutions.jts.io.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) Facet(au.org.ala.legend.Facet)

Aggregations

MapComposer (au.org.emii.portal.composer.MapComposer)38 MapLayer (au.org.emii.portal.menu.MapLayer)20 Listitem (org.zkoss.zul.Listitem)6 HashMap (java.util.HashMap)5 Component (org.zkoss.zk.ui.Component)5 ParseException (com.vividsolutions.jts.io.ParseException)3 JSONObject (org.json.simple.JSONObject)3 ScatterplotDataDTO (au.org.ala.spatial.dto.ScatterplotDataDTO)2 Query (au.org.ala.spatial.util.Query)2 Geometry (com.vividsolutions.jts.geom.Geometry)2 WKTReader (com.vividsolutions.jts.io.WKTReader)2 DateFormat (java.text.DateFormat)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Checkbox (org.zkoss.zul.Checkbox)2 Facet (au.org.ala.legend.Facet)1 ToolComposer (au.org.ala.spatial.composer.tool.ToolComposer)1 PortalSession (au.org.emii.portal.session.PortalSession)1 IsValidOp (com.vividsolutions.jts.operation.valid.IsValidOp)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1