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();
}
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);
}
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);
}
}
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();
}
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;
}
}
}
}
}
Aggregations