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