Search in sources :

Example 16 with MapComposer

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

the class AreaBoundingBox 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 17 with MapComposer

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

the class AreaPointAndRadius 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().addRadiusDrawingTool();
    mc.getOpenLayersJavascript().execute(mc.getOpenLayersJavascript().getIFrameReferences() + script);
    displayGeom.setText("");
    btnNext.setDisabled(true);
    btnClear.setDisabled(true);
}
Also used : MapComposer(au.org.emii.portal.composer.MapComposer)

Example 18 with MapComposer

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

the class AreaPointAndRadius method onSelectionGeom.

/**
     * @param event
     */
public void onSelectionGeom(Event event) {
    String selectionGeom = (String) event.getData();
    try {
        String wkt = "";
        if (selectionGeom.contains(StringConstants.NAN_NAN)) {
            displayGeom.setValue("");
        } else if (selectionGeom.startsWith("LAYER(")) {
            //get WKT from this feature
            String v = selectionGeom.replace("LAYER(", "");
            v = v.substring(0, v.length() - 1);
            //for display
            wkt = Util.wktFromJSON(getMapComposer().getMapLayer(v).getGeoJSON());
            displayGeom.setValue(wkt);
        } else {
            wkt = selectionGeom;
            displayGeom.setValue(wkt);
        }
        //get the current MapComposer instance
        MapComposer mc = getMapComposer();
        //add feature to the map as a new layer
        if (wkt.length() > 0) {
            layerName = (mc.getMapLayer(txtLayerName.getValue()) == null) ? txtLayerName.getValue() : mc.getNextAreaLayerName(txtLayerName.getValue());
            MapLayer mapLayer = mc.addWKTLayer(wkt, layerName, txtLayerName.getValue());
            mapLayer.getMapLayerMetadata().setMoreInfo(LayersUtil.getMetadataForWKT(CommonData.lang(StringConstants.METADATA_POINT_AND_RADIUS), wkt));
        }
        btnNext.setDisabled(false);
        btnClear.setDisabled(false);
    } catch (Exception e) {
        LOGGER.error("error mapping point and radius", e);
    }
}
Also used : MapComposer(au.org.emii.portal.composer.MapComposer) MapLayer(au.org.emii.portal.menu.MapLayer)

Example 19 with MapComposer

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

the class AreaPointAndRadius 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 20 with MapComposer

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

the class AreaMapPolygon method onSearchPoint.

/**
     * Searches the gazetter at a given point and then maps the polygon feature
     * found at the location (for the current top contextual layer).
     *
     * @param event
     */
public void onSearchPoint(Event event) {
    String searchPoint = (String) event.getData();
    String lon = searchPoint.split(",")[0];
    String lat = searchPoint.split(",")[1];
    LOGGER.debug("*************************************");
    LOGGER.debug("CommonData.getLayerList");
    LOGGER.debug("*************************************");
    JSONArray layerlist = CommonData.getLayerListJSONArray();
    MapComposer mc = getMapComposer();
    List<MapLayer> activeLayers = getPortalSession().getActiveLayers();
    Boolean searchComplete = false;
    for (int i = 0; i < activeLayers.size(); i++) {
        MapLayer ml = activeLayers.get(i);
        String activeLayerName = StringConstants.NONE;
        if (ml.getUri() != null) {
            activeLayerName = ml.getUri().replaceAll("^.*&style=", "").replaceAll("&.*", "").replaceAll("_style", "");
        }
        LOGGER.debug("ACTIVE LAYER: " + activeLayerName);
        if (ml.isDisplayed() && ml.isContextualLayer()) {
            for (int j = 0; j < layerlist.size() && !searchComplete; j++) {
                JSONObject field = (JSONObject) layerlist.get(j);
                JSONObject layer = (JSONObject) field.get("layer");
                if (layer.get(StringConstants.TYPE) != null && layer.get(StringConstants.TYPE).toString().length() > 0 && StringConstants.CONTEXTUAL.equalsIgnoreCase(layer.get(StringConstants.TYPE).toString()) && field.get(StringConstants.ID).toString().equalsIgnoreCase(activeLayerName)) {
                    LOGGER.debug(ml.getName());
                    Map<String, String> feature = GazetteerPointSearch.pointSearch(lon, lat, activeLayerName, CommonData.getGeoServer());
                    if (feature == null || !feature.containsKey(StringConstants.PID)) {
                        continue;
                    }
                    layerName = (mc.getMapLayer(txtLayerName.getValue()) == null) ? txtLayerName.getValue() : mc.getNextAreaLayerName(txtLayerName.getValue());
                    getMapComposer().addObjectByPid(feature.get(StringConstants.PID), layerName, 1);
                    //found the object on the layer
                    btnOk.setDisabled(false);
                    btnClear.setDisabled(false);
                    mc.updateLayerControls();
                    searchComplete = true;
                    displayGeom.setValue("layer: " + feature.get(StringConstants.LAYERNAME) + "\r\n" + "area: " + feature.get(StringConstants.VALUE));
                    return;
                }
            }
        }
    }
}
Also used : MapComposer(au.org.emii.portal.composer.MapComposer) JSONObject(org.json.simple.JSONObject) MapLayer(au.org.emii.portal.menu.MapLayer) JSONArray(org.json.simple.JSONArray)

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