use of au.org.emii.portal.menu.MapLayer 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.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.
the class AreaMapPolygon method loadLayerSelection.
public void loadLayerSelection() {
try {
Radio rSelectedLayer = (Radio) getFellowIfAny("rSelectedLayer");
List<MapLayer> layers = getMapComposer().getContextualLayers();
if (!layers.isEmpty()) {
for (int i = 0; i < layers.size(); i++) {
MapLayer lyr = layers.get(i);
Radio rAr = new Radio(lyr.getDisplayName());
rAr.setId(lyr.getDisplayName().replaceAll(" ", ""));
rAr.setValue(lyr.getDisplayName());
rAr.setParent(rgPolygonLayers);
if (i == 0) {
rAr.setSelected(true);
}
rgPolygonLayers.insertBefore(rAr, rSelectedLayer);
}
rSelectedLayer.setSelected(true);
}
} catch (Exception e) {
}
}
use of au.org.emii.portal.menu.MapLayer 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;
}
}
}
}
}
use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.
the class AreaMapPolygon method onClick$btnOk.
public void onClick$btnOk(Event event) {
MapLayer ml = getMapComposer().getMapLayer(layerName);
ml.setDisplayName(txtLayerName.getValue());
getMapComposer().redrawLayersList();
ok = true;
Clients.evalJavaScript("mapFrame.toggleClickHandler(true);");
String activeLayerName = StringConstants.NONE;
if (ml.getUri() != null) {
activeLayerName = ml.getUri().replaceAll("^.*&style=", "").replaceAll("&.*", "").replaceAll("_style", "");
}
getMapComposer().setAttribute("activeLayerName", activeLayerName);
try {
if (rgPolygonLayers.getSelectedItem() == null) {
if (rgPolygonLayers.getItemCount() > 0) {
getMapComposer().setAttribute("mappolygonlayer", rgPolygonLayers.getItemAtIndex(0).getValue());
}
} else {
getMapComposer().setAttribute("mappolygonlayer", rgPolygonLayers.getSelectedItem().getValue());
}
} catch (Exception e) {
LOGGER.error("failed to set map area polygon selected by the radio button selection", e);
}
this.detach();
}
use of au.org.emii.portal.menu.MapLayer in project spatial-portal by AtlasOfLivingAustralia.
the class AddSpeciesInArea method onFinish.
public void onFinish() {
try {
SelectedArea sa = getSelectedArea();
boolean setupMetadata = true;
MapLayer ml = null;
Query q = QueryUtil.queryFromSelectedArea(query, sa, true, geospatialKosher);
if (byLsid) {
ml = getMapComposer().mapSpecies(q, name, s, featureCount, type, null, -1, MapComposer.DEFAULT_POINT_SIZE, MapComposer.DEFAULT_POINT_OPACITY, Util.nextColour(), expertDistributions);
} else if (filter) {
ml = getMapComposer().mapSpecies(q, name, s, featureCount, type, null, -1, MapComposer.DEFAULT_POINT_SIZE, MapComposer.DEFAULT_POINT_OPACITY, Util.nextColour(), expertDistributions);
} else if (filterGrid) {
ml = getMapComposer().mapSpecies(q, name, s, featureCount, type, null, -1, MapComposer.DEFAULT_POINT_SIZE, MapComposer.DEFAULT_POINT_OPACITY, Util.nextColour(), expertDistributions);
} else if (rank != null && taxon != null && q != null) {
ml = getMapComposer().mapSpecies(q, taxon, rank, -1, LayerUtilitiesImpl.SPECIES, null, -1, MapComposer.DEFAULT_POINT_SIZE, MapComposer.DEFAULT_POINT_OPACITY, Util.nextColour(), expertDistributions);
setupMetadata = false;
} else {
int resultsCountOccurrences = q.getOccurrenceCount();
//test limit
if (resultsCountOccurrences > 0 && resultsCountOccurrences <= Integer.parseInt(CommonData.getSettings().getProperty(StringConstants.MAX_RECORD_COUNT_MAP))) {
String activeAreaLayerName = getSelectedAreaDisplayName();
String layerName = CommonData.lang("occurrences_in_area_prefix") + " " + activeAreaLayerName;
if (multipleSpeciesUploadName != null) {
layerName = multipleSpeciesUploadName;
} else {
if (q instanceof BiocacheQuery) {
String lsids = ((BiocacheQuery) q).getLsids();
if (lsids != null && lsids.length() > 0 && lsids.split(",").length > 1) {
layerName = CommonData.lang("species_assemblage_layer_name");
}
}
}
ml = getMapComposer().mapSpecies(q, layerName, StringConstants.SPECIES, resultsCountOccurrences, LayerUtilitiesImpl.SPECIES, null, -1, MapComposer.DEFAULT_POINT_SIZE, MapComposer.DEFAULT_POINT_OPACITY, Util.nextColour(), expertDistributions);
} else {
getMapComposer().showMessage(CommonData.lang("error_too_many_occurrences_for_mapping").replace("<counted_occurrences>", resultsCountOccurrences + "").replace("<max_occurrences>", CommonData.getSettings().getProperty(StringConstants.MAX_RECORD_COUNT_MAP)));
}
setupMetadata = false;
}
if (setupMetadata) {
ml.getMapLayerMetadata().setMoreInfo(metadata);
}
LOGGER.debug("metadata: " + metadata);
} catch (Exception e) {
LOGGER.error("error adding species in area to map", e);
}
}
Aggregations