Search in sources :

Example 1 with BoundingBox

use of au.org.emii.portal.value.BoundingBox in project spatial-portal by AtlasOfLivingAustralia.

the class LeftMenuSearchComposer method triggerViewportChange.

public void triggerViewportChange(Event e) throws Exception {
    //update bounding box for this session
    BoundingBox bb = new BoundingBox();
    bb.setMinLatitude((float) south);
    bb.setMaxLatitude((float) north);
    bb.setMinLongitude((float) west);
    bb.setMaxLongitude((float) east);
    //don't want to update this when map is not fully loaded
    if (getPortalSession().isMapLoaded()) {
        getMapComposer().getPortalSession().setDefaultBoundingbox(bb);
    }
    for (EventListener el : viewportChangeEvents.values()) {
        try {
            el.onEvent(null);
        } catch (Exception ex) {
            LOGGER.error("error running viewport change listener", ex);
        }
    }
}
Also used : BoundingBox(au.org.emii.portal.value.BoundingBox) EventListener(org.zkoss.zk.ui.event.EventListener)

Example 2 with BoundingBox

use of au.org.emii.portal.value.BoundingBox in project spatial-portal by AtlasOfLivingAustralia.

the class LeftMenuSearchComposer method getViewportBoundingBox.

public BoundingBox getViewportBoundingBox() {
    BoundingBox bbox = new BoundingBox();
    bbox.setMaxLatitude((float) north);
    bbox.setMinLatitude((float) south);
    bbox.setMinLongitude((float) west);
    bbox.setMaxLongitude((float) east);
    return bbox;
}
Also used : BoundingBox(au.org.emii.portal.value.BoundingBox)

Example 3 with BoundingBox

use of au.org.emii.portal.value.BoundingBox in project spatial-portal by AtlasOfLivingAustralia.

the class ConfigurationLoaderStage2Impl method defaultBoundingBox.

/**
     * Process a bounding box declaration
     */
private BoundingBox defaultBoundingBox() {
    BoundingBox bbox = new BoundingBox();
    try {
        bbox.setMinLatitude(Float.parseFloat(portalDocument.getProperty("defaultBoundingBox.minLatitude")));
        bbox.setMaxLatitude(Float.parseFloat(portalDocument.getProperty("defaultBoundingBox.maxLatitude")));
        bbox.setMinLongitude(Float.parseFloat(portalDocument.getProperty("defaultBoundingBox.minLongitude")));
        bbox.setMaxLongitude(Float.parseFloat(portalDocument.getProperty("defaultBoundingBox.maxLongitude")));
    } catch (Exception e) {
        LOGGER.error("failed to parse defaultBoundBox values", e);
    }
    return bbox;
}
Also used : BoundingBox(au.org.emii.portal.value.BoundingBox)

Example 4 with BoundingBox

use of au.org.emii.portal.value.BoundingBox in project spatial-portal by AtlasOfLivingAustralia.

the class LayerLegendGeneralComposer method setupForClassificationLayers.

private void setupForClassificationLayers() {
    if (mapLayer.isPolygonLayer())
        return;
    String activeLayerName = StringConstants.NONE;
    JSONObject field = null;
    JSONObject layer = null;
    if (mapLayer != null && mapLayer.getUri() != null) {
        if (mapLayer.getBaseUri() != null) {
            activeLayerName = mapLayer.getBaseUri().replaceAll("^.*&style=", "").replaceAll("&.*", "").replaceAll("_style", "");
        } else {
            activeLayerName = mapLayer.getUri().replaceAll("^.*&style=", "").replaceAll("&.*", "").replaceAll("_style", "");
        }
        field = CommonData.getLayer(activeLayerName);
        if (field == null)
            return;
        layer = (JSONObject) field.get("layer");
    }
    LOGGER.debug("ACTIVE LAYER: " + activeLayerName);
    if (mapLayer != null && mapLayer.getSubType() == LayerUtilitiesImpl.ALOC) {
        divClassificationPicker.setVisible(true);
        //reset content
        Integer groupCount = mapLayer.getClassificationGroupCount();
        if (groupCount == null) {
            mapLayer.setClassificationGroupCount(getClassificationGroupCount(mapLayer.getName().replace("aloc_", "")));
            groupCount = 0;
        }
        for (int i = cbClassificationGroup.getItemCount() - 1; i >= 0; i--) {
            cbClassificationGroup.removeItemAt(i);
        }
        Comboitem ci = new Comboitem(StringConstants.NONE);
        ci.setParent(cbClassificationGroup);
        for (int i = 1; i <= groupCount; i++) {
            new Comboitem("Group " + i).setParent(cbClassificationGroup);
        }
        //is there a current selection?
        Integer groupSelection = mapLayer.getClassificationSelection();
        if (groupSelection == null) {
            groupSelection = 0;
            mapLayer.setClassificationSelection(groupSelection);
        }
        cbClassificationGroup.setSelectedIndex(groupSelection);
        getFellow("btnCreateArea").setVisible(false);
        cbClassificationGroup.setVisible(true);
        lbClassificationGroup.setVisible(false);
        hboxClassificationGroup.setVisible(false);
    } else if (layer != null && layer.containsKey("type") && layer.get("type").toString().equalsIgnoreCase("contextual")) {
        divClassificationPicker.setVisible(true);
        if (mapLayer.getClassificationGroupCount() == null || mapLayer.getClassificationGroupCount() == 0) {
            //build
            String fieldId = field.get(StringConstants.ID).toString();
            JSONParser jp = new JSONParser();
            JSONObject objJson = null;
            try {
                objJson = (JSONObject) jp.parse(Util.readUrl(CommonData.getLayersServer() + "/field/" + fieldId));
            } catch (ParseException e) {
                LOGGER.error("failed to parse for: " + fieldId);
            }
            JSONArray objects = (JSONArray) objJson.get("objects");
            //sort
            List<JSONObject> list = objects.subList(0, objects.size());
            Collections.sort(list, new Comparator<JSONObject>() {

                @Override
                public int compare(JSONObject o1, JSONObject o2) {
                    String s1 = (o1 == null || !o1.containsKey("name")) ? "" : o1.get("name").toString();
                    String s2 = (o2 == null || !o2.containsKey("name")) ? "" : o2.get("name").toString();
                    return s1.compareTo(s2);
                }
            });
            JSONArray obj = new JSONArray();
            obj.addAll(list);
            mapLayer.setClassificationGroupCount(obj.size());
            mapLayer.setClassificationObjects(obj);
        }
        //reset content
        Integer groupCount = mapLayer.getClassificationGroupCount();
        JSONArray groupObjects = mapLayer.getClassificationObjects();
        lbClassificationGroup.setItemRenderer(new ListitemRenderer<JSONObject>() {

            @Override
            public void render(Listitem item, JSONObject data, int index) throws Exception {
                Checkbox cb = new Checkbox();
                final int idx = index;
                cb.addEventListener("onCheck", new EventListener<Event>() {

                    @Override
                    public void onEvent(Event event) throws Exception {
                        if (mapLayer != null) {
                            lbClassificationGroup.setMultiple(true);
                            String v = ((Listcell) event.getTarget().getParent().getParent().getChildren().get(1)).getLabel();
                            if (((CheckEvent) event).isChecked()) {
                                selectedList.add(v);
                            } else {
                                selectedList.remove(v);
                            }
                            lblSelectedCount.setValue(selectedList.size() + " checked");
                            getFellow("clearSelection").setVisible(selectedList.size() > 0);
                            getFellow("createInGroup").setVisible(selectedList.size() > 0);
                            if (getFellowIfAny("createOutGroup") != null)
                                getFellow("createOutGroup").setVisible(selectedList.size() > 0);
                            highlightSelect(idx);
                        }
                    }
                });
                determineCheckboxState(cb, data.get("name").toString());
                Listcell lc;
                lc = new Listcell();
                cb.setParent(lc);
                lc.setParent(item);
                lc = new Listcell(data.get("name").toString());
                lc.setParent(item);
                lc = new Listcell();
                Image img = new Image();
                img.setTooltip("Create as an area layer");
                img.setClass("icon-plus-sign");
                img.setParent(lc);
                lc.setParent(item);
                final JSONObject j = data;
                img.addEventListener("onClick", new EventListener<Event>() {

                    @Override
                    public void onEvent(Event event) throws Exception {
                        createAreaEcho(j.get("pid").toString());
                    }
                });
                lc = new Listcell();
                img = new Image();
                img.setTooltip("Zoom to area");
                img.setClass("icon-zoom-in");
                img.setParent(lc);
                lc.setParent(item);
                img.addEventListener("onClick", new EventListener<Event>() {

                    @Override
                    public void onEvent(Event event) throws Exception {
                        List<Double> b = Util.getBoundingBox(j.get("bbox").toString());
                        BoundingBox bbox = new BoundingBox();
                        bbox.setMinLongitude(b.get(0).floatValue());
                        bbox.setMinLatitude(b.get(1).floatValue());
                        bbox.setMaxLongitude(b.get(2).floatValue());
                        bbox.setMaxLatitude(b.get(3).floatValue());
                        getMapComposer().getOpenLayersJavascript().execute(getMapComposer().getOpenLayersJavascript().zoomToBoundingBox(bbox, false));
                    }
                });
            }
        });
        lbClassificationGroup.addEventListener("onSelect", new EventListener<Event>() {

            @Override
            public void onEvent(Event event) throws Exception {
                if (mapLayer != null) {
                    highlightSelect(lbClassificationGroup.getSelectedIndex());
                }
            }
        });
        List<JSONObject> model = new ArrayList<JSONObject>();
        for (int i = 0; i < groupCount; i++) {
            model.add((JSONObject) groupObjects.get(i));
        }
        lbClassificationGroup.setModel(new SimpleListModel(model));
        //is there a current selection?
        Integer groupSelection = mapLayer.getClassificationSelection();
        if (groupSelection == null) {
            groupSelection = 0;
            mapLayer.setClassificationSelection(groupSelection);
        }
        getFellow("btnCreateArea").setVisible(true);
        getFellow("btnCreateArea").setVisible(false);
        cbClassificationGroup.setVisible(false);
        lbClassificationGroup.setVisible(true);
        hboxClassificationGroup.setVisible(true);
    } else {
        getFellow("btnCreateArea").setVisible(false);
        divClassificationPicker.setVisible(false);
    }
}
Also used : JSONArray(org.json.simple.JSONArray) Image(org.zkoss.zul.Image) ParseException(org.json.simple.parser.ParseException) JSONObject(org.json.simple.JSONObject) Checkbox(org.zkoss.zul.Checkbox) BoundingBox(au.org.emii.portal.value.BoundingBox) CheckEvent(org.zkoss.zk.ui.event.CheckEvent) Event(org.zkoss.zk.ui.event.Event) JSONParser(org.json.simple.parser.JSONParser) List(java.util.List) ParseException(org.json.simple.parser.ParseException) EventListener(org.zkoss.zk.ui.event.EventListener)

Example 5 with BoundingBox

use of au.org.emii.portal.value.BoundingBox in project spatial-portal by AtlasOfLivingAustralia.

the class MapComposer method mapLoaded.

public void mapLoaded(String text) {
    boolean loaded = Boolean.parseBoolean(text);
    getPortalSession().setMapLoaded(loaded);
    BoundingBox bb = getPortalSession().getDefaultBoundingBox();
    if (loaded) {
        LOGGER.debug("map is now loaded. let's try mapping.");
        MapLayer ml = loadUrlParameters();
        if (ml == null) {
            openLayersJavascript.useAdditionalScript();
        }
    }
    openLayersJavascript.zoomToBoundingBox(bb, false);
}
Also used : BoundingBox(au.org.emii.portal.value.BoundingBox) HasMapLayer(au.org.emii.portal.menu.HasMapLayer) MapLayer(au.org.emii.portal.menu.MapLayer)

Aggregations

BoundingBox (au.org.emii.portal.value.BoundingBox)7 HasMapLayer (au.org.emii.portal.menu.HasMapLayer)2 MapLayer (au.org.emii.portal.menu.MapLayer)2 List (java.util.List)2 JSONObject (org.json.simple.JSONObject)2 ParseException (org.json.simple.parser.ParseException)2 EventListener (org.zkoss.zk.ui.event.EventListener)2 LegendObject (au.org.ala.legend.LegendObject)1 ScatterplotDataDTO (au.org.ala.spatial.dto.ScatterplotDataDTO)1 XStream (com.thoughtworks.xstream.XStream)1 DataHolder (com.thoughtworks.xstream.converters.DataHolder)1 HierarchicalStreamReader (com.thoughtworks.xstream.io.HierarchicalStreamReader)1 DomDriver (com.thoughtworks.xstream.io.xml.DomDriver)1 MapperWrapper (com.thoughtworks.xstream.mapper.MapperWrapper)1 FilePersistenceStrategy (com.thoughtworks.xstream.persistence.FilePersistenceStrategy)1 PersistenceStrategy (com.thoughtworks.xstream.persistence.PersistenceStrategy)1 XmlArrayList (com.thoughtworks.xstream.persistence.XmlArrayList)1 JSONArray (org.json.simple.JSONArray)1 JSONParser (org.json.simple.parser.JSONParser)1 CheckEvent (org.zkoss.zk.ui.event.CheckEvent)1