|
|
|
@ -107,11 +107,11 @@ public class LayerManager {
|
|
|
|
|
GWT.log("(" + selectDataInfo.getX1() + "," + selectDataInfo.getY1() + ")(" + selectDataInfo.getX2()
|
|
|
|
|
+ "," + selectDataInfo.getY2() + ")");
|
|
|
|
|
|
|
|
|
|
for (LayerObject layerObj : layerObjects.values()) {
|
|
|
|
|
// TODO
|
|
|
|
|
isLayerVisible(layerObj.getLayerItem());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// for (LayerObject layerObj : layerObjects.values()) {
|
|
|
|
|
// // TODO
|
|
|
|
|
// isLayerVisible(layerObj.getLayerItem());
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
BoundsMap mapBBOX = new BoundsMap();
|
|
|
|
|
// THIS IS SHOULD BE CORRET, THE BOUND AND CRS ARE READ FROM MAP
|
|
|
|
@ -227,6 +227,8 @@ public class LayerManager {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GWT.log("the product id is: " + theProductId);
|
|
|
|
|
//Displaying popup info for centroid layer
|
|
|
|
|
showPopupInfoForCentroidLayer(geoNaDataObject, feature, queryEvent.getOnFailureCenterTo());
|
|
|
|
|
|
|
|
|
|
// retrieving and showing WMS layers of a concessione if the ZOOM level is >
|
|
|
|
|
// QUERY_MIN_ZOOM_LEVEL
|
|
|
|
@ -260,195 +262,185 @@ public class LayerManager {
|
|
|
|
|
olMap.removeAllDetailLayers();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if(queryEvent.getSourceMapEventType() != null && queryEvent.getSourceMapEventType().equals(MapEventType.MAP_ZOOM_END)) {
|
|
|
|
|
// GWT.log("EVENT IS "+MapEventType.MAP_ZOOM_END +" retuning");
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Showing properties belonging to concessioni centroid layer
|
|
|
|
|
Map<String, List<String>> entries = feature.getMapProperties();
|
|
|
|
|
|
|
|
|
|
String nome = "";
|
|
|
|
|
String descrizione = "";
|
|
|
|
|
String date = "";
|
|
|
|
|
|
|
|
|
|
for (String key : entries.keySet()) {
|
|
|
|
|
String theValue = entries.get(key).get(0);
|
|
|
|
|
if (key.equalsIgnoreCase("nome")) {
|
|
|
|
|
nome = theValue != null ? theValue : "";
|
|
|
|
|
} else if (key.equalsIgnoreCase("descrizione")) {
|
|
|
|
|
descrizione = theValue != null ? theValue : "";
|
|
|
|
|
} else if (key.equalsIgnoreCase("date_scavo")) {
|
|
|
|
|
date = theValue != null ? theValue : "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// Map<String, List<String>> entries = feature.getMapProperties();
|
|
|
|
|
//
|
|
|
|
|
// String nome = "";
|
|
|
|
|
// String descrizione = "";
|
|
|
|
|
// String date = "";
|
|
|
|
|
//
|
|
|
|
|
// for (String key : entries.keySet()) {
|
|
|
|
|
// String theValue = entries.get(key).get(0);
|
|
|
|
|
// if (key.equalsIgnoreCase("nome")) {
|
|
|
|
|
// nome = theValue != null ? theValue : "";
|
|
|
|
|
// } else if (key.equalsIgnoreCase("descrizione")) {
|
|
|
|
|
// descrizione = theValue != null ? theValue : "";
|
|
|
|
|
// } else if (key.equalsIgnoreCase("date_scavo")) {
|
|
|
|
|
// date = theValue != null ? theValue : "";
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// GeoportalDataViewerConstants.print("0: "+nome);
|
|
|
|
|
flex.setHTML(0, 0, new HTML(nome).toString());
|
|
|
|
|
try {
|
|
|
|
|
descrizione = StringUtil.ellipsize(descrizione, 100);
|
|
|
|
|
GWT.log("reduced: " + descrizione);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
GWT.log("error: " + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
// GeoportalDataViewerConstants.print("1: "+descrizione);
|
|
|
|
|
flex.setText(1, 0, descrizione);
|
|
|
|
|
// GeoportalDataViewerConstants.print("2: "+date);
|
|
|
|
|
date = StringUtil.formatDate(date);
|
|
|
|
|
flex.setHTML(2, 0, new HTML("<code>" + date + "</code>").toString());
|
|
|
|
|
|
|
|
|
|
if (geoNaDataObject.getMapImages() != null) {
|
|
|
|
|
for (String key : geoNaDataObject.getMapImages().keySet()) {
|
|
|
|
|
List<UploadedImageDV> listUI = geoNaDataObject.getMapImages()
|
|
|
|
|
.get(key);
|
|
|
|
|
GWT.log("Adding images: " + listUI);
|
|
|
|
|
if (listUI != null && listUI.size() > 0) {
|
|
|
|
|
UploadedImageDV img = listUI.get(0);
|
|
|
|
|
if (img.getListWsContent() != null) {
|
|
|
|
|
WorkspaceContentDV wsContent = img.getListWsContent()
|
|
|
|
|
.get(img.getListWsContent().size() - 1);
|
|
|
|
|
String theImgHTML = "<img src=\"" + wsContent.getLink()
|
|
|
|
|
+ "\"></img>";
|
|
|
|
|
GWT.log("theImgHTML: " + theImgHTML);
|
|
|
|
|
// GeoportalDataViewerConstants.print("The row are:
|
|
|
|
|
// "+flex.getRowCount());
|
|
|
|
|
flex.setHTML(flex.getRowCount() + 1, 0, theImgHTML);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
featureFound = true;
|
|
|
|
|
// flex.setHTML(0, 0, new HTML(nome).toString());
|
|
|
|
|
// try {
|
|
|
|
|
// descrizione = StringUtil.ellipsize(descrizione, 100);
|
|
|
|
|
// GWT.log("reduced: " + descrizione);
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
// GWT.log("error: " + e.getMessage());
|
|
|
|
|
// }
|
|
|
|
|
// // GeoportalDataViewerConstants.print("1: "+descrizione);
|
|
|
|
|
// flex.setText(1, 0, descrizione);
|
|
|
|
|
// // GeoportalDataViewerConstants.print("2: "+date);
|
|
|
|
|
// date = StringUtil.formatDate(date);
|
|
|
|
|
// flex.setHTML(2, 0, new HTML("<code>" + date + "</code>").toString());
|
|
|
|
|
|
|
|
|
|
// if (geoNaDataObject.getMapImages() != null) {
|
|
|
|
|
// for (String key : geoNaDataObject.getMapImages().keySet()) {
|
|
|
|
|
// List<UploadedImageDV> listUI = geoNaDataObject.getMapImages()
|
|
|
|
|
// .get(key);
|
|
|
|
|
// GWT.log("Adding images: " + listUI);
|
|
|
|
|
// if (listUI != null && listUI.size() > 0) {
|
|
|
|
|
// UploadedImageDV img = listUI.get(0);
|
|
|
|
|
// if (img.getListWsContent() != null) {
|
|
|
|
|
// WorkspaceContentDV wsContent = img.getListWsContent()
|
|
|
|
|
// .get(img.getListWsContent().size() - 1);
|
|
|
|
|
// String theImgHTML = "<img src=\"" + wsContent.getLink()
|
|
|
|
|
// + "\"></img>";
|
|
|
|
|
// GWT.log("theImgHTML: " + theImgHTML);
|
|
|
|
|
// // GeoportalDataViewerConstants.print("The row are:
|
|
|
|
|
// // "+flex.getRowCount());
|
|
|
|
|
// flex.setHTML(flex.getRowCount() + 1, 0, theImgHTML);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// featureFound = true;
|
|
|
|
|
// break; //Only the first one
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (feature == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
GWT.log("The selected Feature is: " + feature);
|
|
|
|
|
// GeoportalDataViewerConstants.print("The selected Feature is: "+feature);
|
|
|
|
|
FeatureRow theFeature = feature;
|
|
|
|
|
Button button = null;
|
|
|
|
|
if (!featureFound) {
|
|
|
|
|
flex.setHTML(0, 0, new HTML("No data available").toString());
|
|
|
|
|
} else {
|
|
|
|
|
button = new Button("Open Details");
|
|
|
|
|
button.getElement().setId("open-details");
|
|
|
|
|
button.setType(ButtonType.LINK);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VerticalPanel vpPanel = new VerticalPanel();
|
|
|
|
|
vpPanel.add(flex);
|
|
|
|
|
|
|
|
|
|
if (button != null) {
|
|
|
|
|
vpPanel.add(button);
|
|
|
|
|
button.setType(ButtonType.LINK);
|
|
|
|
|
button.addClickHandler(new ClickHandler() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(ClickEvent event) {
|
|
|
|
|
ShowDetailsEvent toEvent = parseGeonaReferences(
|
|
|
|
|
geoNaDataObject.getSourceLayerObject().getItemType(),
|
|
|
|
|
theFeature);
|
|
|
|
|
applicationBus.fireEvent(toEvent);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
// if (feature == null)
|
|
|
|
|
// return;
|
|
|
|
|
//
|
|
|
|
|
// GWT.log("The selected Feature is: " + feature);
|
|
|
|
|
// // GeoportalDataViewerConstants.print("The selected Feature is: "+feature);
|
|
|
|
|
// FeatureRow theFeature = feature;
|
|
|
|
|
// Button button = null;
|
|
|
|
|
// if (!featureFound) {
|
|
|
|
|
// flex.setHTML(0, 0, new HTML("No data available").toString());
|
|
|
|
|
// } else {
|
|
|
|
|
// button = new Button("Open Details");
|
|
|
|
|
// button.getElement().setId("open-details");
|
|
|
|
|
// button.setType(ButtonType.LINK);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// VerticalPanel vpPanel = new VerticalPanel();
|
|
|
|
|
// vpPanel.add(flex);
|
|
|
|
|
|
|
|
|
|
Coordinate centerTo = null;
|
|
|
|
|
GWT.log("geometry is: " + feature.getGeometry());
|
|
|
|
|
if (feature.getGeometry() != null) {
|
|
|
|
|
GWT.log("trasforming geometry: " + feature.getGeometry().getToJSONObject());
|
|
|
|
|
|
|
|
|
|
Geometry geom = new GeoJson()
|
|
|
|
|
.readGeometry(feature.getGeometry().getToJSONObject(), null);
|
|
|
|
|
|
|
|
|
|
//POINT
|
|
|
|
|
if (geom.getType().equalsIgnoreCase("Point")) {
|
|
|
|
|
GWT.log("geometry: is a point");
|
|
|
|
|
String coordinateJSON = feature.getGeometry().getCoordinatesJSON();
|
|
|
|
|
JSONArray centerJSON = (JSONArray) JSONParser
|
|
|
|
|
.parseStrict(coordinateJSON);
|
|
|
|
|
// Coordinate center = OLFactory.createCoordinate(
|
|
|
|
|
// if (button != null) {
|
|
|
|
|
// vpPanel.add(button);
|
|
|
|
|
// button.setType(ButtonType.LINK);
|
|
|
|
|
// button.addClickHandler(new ClickHandler() {
|
|
|
|
|
//
|
|
|
|
|
// @Override
|
|
|
|
|
// public void onClick(ClickEvent event) {
|
|
|
|
|
// ShowDetailsEvent toEvent = parseGeonaReferences(
|
|
|
|
|
// geoNaDataObject.getSourceLayerObject().getItemType(),
|
|
|
|
|
// theFeature);
|
|
|
|
|
// applicationBus.fireEvent(toEvent);
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// Coordinate centerTo = null;
|
|
|
|
|
// GWT.log("geometry is: " + feature.getGeometry());
|
|
|
|
|
// if (feature.getGeometry() != null) {
|
|
|
|
|
// GWT.log("trasforming geometry: " + feature.getGeometry().getToJSONObject());
|
|
|
|
|
//
|
|
|
|
|
// Geometry geom = new GeoJson()
|
|
|
|
|
// .readGeometry(feature.getGeometry().getToJSONObject(), null);
|
|
|
|
|
//
|
|
|
|
|
// // POINT
|
|
|
|
|
// if (geom.getType().equalsIgnoreCase("Point")) {
|
|
|
|
|
// GWT.log("geometry: is a point");
|
|
|
|
|
// String coordinateJSON = feature.getGeometry().getCoordinatesJSON();
|
|
|
|
|
// JSONArray centerJSON = (JSONArray) JSONParser
|
|
|
|
|
// .parseStrict(coordinateJSON);
|
|
|
|
|
//// Coordinate center = OLFactory.createCoordinate(
|
|
|
|
|
//// new Double(centerJSON.get(0).toString()),
|
|
|
|
|
//// new Double(centerJSON.get(1).toString()));
|
|
|
|
|
//
|
|
|
|
|
// Coordinate center = new Coordinate(
|
|
|
|
|
// new Double(centerJSON.get(0).toString()),
|
|
|
|
|
// new Double(centerJSON.get(1).toString()));
|
|
|
|
|
|
|
|
|
|
Coordinate center = new Coordinate(new Double(centerJSON.get(0).toString()),
|
|
|
|
|
new Double(centerJSON.get(1).toString()));
|
|
|
|
|
|
|
|
|
|
if (feature.getCrsName() != null && feature.getCrsName().endsWith(MAP_PROJECTION.EPSG_4326.getId())) {
|
|
|
|
|
|
|
|
|
|
center = MapUtils.transformCoordiante(center,
|
|
|
|
|
MAP_PROJECTION.EPSG_4326.getName(),
|
|
|
|
|
MAP_PROJECTION.EPSG_3857.getName());
|
|
|
|
|
}
|
|
|
|
|
centerTo = center;
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
Extent geomExtent = geom.getExtent();
|
|
|
|
|
|
|
|
|
|
Coordinate lower = OLFactory.createCoordinate(
|
|
|
|
|
geomExtent.getLowerLeftX(), geomExtent.getLowerLeftY());
|
|
|
|
|
Coordinate upper = OLFactory.createCoordinate(
|
|
|
|
|
geomExtent.getUpperRightX(), geomExtent.getUpperRightY());
|
|
|
|
|
Coordinate lowerCoord = lower;
|
|
|
|
|
Coordinate upperCoord = upper;
|
|
|
|
|
if (feature.getCrsName() != null && feature.getCrsName()
|
|
|
|
|
.endsWith(MAP_PROJECTION.EPSG_4326.getId())) {
|
|
|
|
|
|
|
|
|
|
lowerCoord = MapUtils.transformCoordiante(lower,
|
|
|
|
|
MAP_PROJECTION.EPSG_4326.getName(),
|
|
|
|
|
MAP_PROJECTION.EPSG_3857.getName());
|
|
|
|
|
upperCoord = MapUtils.transformCoordiante(upper,
|
|
|
|
|
MAP_PROJECTION.EPSG_4326.getName(),
|
|
|
|
|
MAP_PROJECTION.EPSG_3857.getName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ExtentWrapped ew = new ExtentWrapped(lowerCoord.getX(),
|
|
|
|
|
lowerCoord.getY(), upperCoord.getX(), upperCoord.getY());
|
|
|
|
|
|
|
|
|
|
centerTo = new Coordinate(ew.getCenter().getX(), ew.getCenter().getY());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
GWT.log("center is: "+centerTo);
|
|
|
|
|
// PointsPath path = feature.getGeometry().getPath();
|
|
|
|
|
// GWT.log("Points Path: " + path);
|
|
|
|
|
// if (path != null && path.getCoordinates() != null
|
|
|
|
|
// && path.getCoordinates().length > 0) {
|
|
|
|
|
// org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.Coordinate center = path
|
|
|
|
|
// .getCoordinates()[0];
|
|
|
|
|
// centerTo = new Coordinate(center.getX(), center.getY());
|
|
|
|
|
//
|
|
|
|
|
// if (feature.getCrsName() != null && feature.getCrsName()
|
|
|
|
|
// .endsWith(MAP_PROJECTION.EPSG_4326.getId())) {
|
|
|
|
|
//
|
|
|
|
|
// center = MapUtils.transformCoordiante(center,
|
|
|
|
|
// MAP_PROJECTION.EPSG_4326.getName(),
|
|
|
|
|
// MAP_PROJECTION.EPSG_3857.getName());
|
|
|
|
|
// }
|
|
|
|
|
// centerTo = center;
|
|
|
|
|
// } else {
|
|
|
|
|
//
|
|
|
|
|
// Extent geomExtent = geom.getExtent();
|
|
|
|
|
//
|
|
|
|
|
// Coordinate lower = OLFactory.createCoordinate(
|
|
|
|
|
// geomExtent.getLowerLeftX(), geomExtent.getLowerLeftY());
|
|
|
|
|
// Coordinate upper = OLFactory.createCoordinate(
|
|
|
|
|
// geomExtent.getUpperRightX(), geomExtent.getUpperRightY());
|
|
|
|
|
// Coordinate lowerCoord = lower;
|
|
|
|
|
// Coordinate upperCoord = upper;
|
|
|
|
|
// if (feature.getCrsName() != null && feature.getCrsName()
|
|
|
|
|
// .endsWith(MAP_PROJECTION.EPSG_4326.getId())) {
|
|
|
|
|
//
|
|
|
|
|
// lowerCoord = MapUtils.transformCoordiante(lower,
|
|
|
|
|
// MAP_PROJECTION.EPSG_4326.getName(),
|
|
|
|
|
// MAP_PROJECTION.EPSG_3857.getName());
|
|
|
|
|
// upperCoord = MapUtils.transformCoordiante(upper,
|
|
|
|
|
// MAP_PROJECTION.EPSG_4326.getName(),
|
|
|
|
|
// MAP_PROJECTION.EPSG_3857.getName());
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// ExtentWrapped ew = new ExtentWrapped(lowerCoord.getX(),
|
|
|
|
|
// lowerCoord.getY(), upperCoord.getX(), upperCoord.getY());
|
|
|
|
|
//
|
|
|
|
|
// centerTo = new Coordinate(ew.getCenter().getX(), ew.getCenter().getY());
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
// GWT.log("center is: " + centerTo);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// fallback
|
|
|
|
|
if (centerTo == null)
|
|
|
|
|
centerTo = queryEvent.getOnFailureCenterTo();
|
|
|
|
|
|
|
|
|
|
olMap.showPopup(vpPanel.toString(), centerTo);
|
|
|
|
|
|
|
|
|
|
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void execute() {
|
|
|
|
|
Element buttonElement = DOM.getElementById("open-details");
|
|
|
|
|
Event.sinkEvents(buttonElement, Event.ONCLICK);
|
|
|
|
|
Event.setEventListener(buttonElement, new EventListener() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onBrowserEvent(Event event) {
|
|
|
|
|
if (Event.ONCLICK == event.getTypeInt()) {
|
|
|
|
|
ShowDetailsEvent toEvent = parseGeonaReferences(
|
|
|
|
|
geoNaDataObject.getSourceLayerObject()
|
|
|
|
|
.getItemType(),
|
|
|
|
|
theFeature);
|
|
|
|
|
applicationBus.fireEvent(toEvent);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
// // fallback
|
|
|
|
|
// if (centerTo == null)
|
|
|
|
|
// centerTo = queryEvent.getOnFailureCenterTo();
|
|
|
|
|
//
|
|
|
|
|
// olMap.showPopup(vpPanel.toString(), centerTo);
|
|
|
|
|
//
|
|
|
|
|
// Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
|
|
|
|
//
|
|
|
|
|
// @Override
|
|
|
|
|
// public void execute() {
|
|
|
|
|
// Element buttonElement = DOM.getElementById("open-details");
|
|
|
|
|
// Event.sinkEvents(buttonElement, Event.ONCLICK);
|
|
|
|
|
// Event.setEventListener(buttonElement, new EventListener() {
|
|
|
|
|
//
|
|
|
|
|
// @Override
|
|
|
|
|
// public void onBrowserEvent(Event event) {
|
|
|
|
|
// if (Event.ONCLICK == event.getTypeInt()) {
|
|
|
|
|
// ShowDetailsEvent toEvent = parseGeonaReferences(
|
|
|
|
|
// geoNaDataObject.getSourceLayerObject()
|
|
|
|
|
// .getItemType(),
|
|
|
|
|
// theFeature);
|
|
|
|
|
// applicationBus.fireEvent(toEvent);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
@ -663,6 +655,179 @@ public class LayerManager {
|
|
|
|
|
return layerItem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Show popup info for centroid layer.
|
|
|
|
|
*
|
|
|
|
|
* @param geoNaDataObject the geo na data object
|
|
|
|
|
* @param feature the feature
|
|
|
|
|
* @param onFailureCenterTo the on failure center to
|
|
|
|
|
*/
|
|
|
|
|
public void showPopupInfoForCentroidLayer(GeoNaSpatialQueryResult geoNaDataObject, FeatureRow feature,
|
|
|
|
|
Coordinate onFailureCenterTo) {
|
|
|
|
|
|
|
|
|
|
FlexTable flex = new FlexTable();
|
|
|
|
|
flex.setCellPadding(1);
|
|
|
|
|
flex.setCellSpacing(1);
|
|
|
|
|
flex.getElement().addClassName("popup-table");
|
|
|
|
|
VerticalPanel vpPanel = new VerticalPanel();
|
|
|
|
|
vpPanel.add(flex);
|
|
|
|
|
|
|
|
|
|
if (feature == null) {
|
|
|
|
|
olMap.showPopup(vpPanel.toString(), onFailureCenterTo);
|
|
|
|
|
flex.setHTML(0, 0, new HTML("No data available").toString());
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Showing properties belonging to concessioni centroid layer
|
|
|
|
|
Map<String, List<String>> entries = feature.getMapProperties();
|
|
|
|
|
|
|
|
|
|
String nome = "";
|
|
|
|
|
String descrizione = "";
|
|
|
|
|
String date = "";
|
|
|
|
|
|
|
|
|
|
for (String key : entries.keySet()) {
|
|
|
|
|
String theValue = entries.get(key).get(0);
|
|
|
|
|
if (key.equalsIgnoreCase("nome")) {
|
|
|
|
|
nome = theValue != null ? theValue : "";
|
|
|
|
|
} else if (key.equalsIgnoreCase("descrizione")) {
|
|
|
|
|
descrizione = theValue != null ? theValue : "";
|
|
|
|
|
} else if (key.equalsIgnoreCase("date_scavo")) {
|
|
|
|
|
date = theValue != null ? theValue : "";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// GeoportalDataViewerConstants.print("0: "+nome);
|
|
|
|
|
flex.setHTML(0, 0, new HTML(nome).toString());
|
|
|
|
|
try {
|
|
|
|
|
descrizione = StringUtil.ellipsize(descrizione, 100);
|
|
|
|
|
GWT.log("reduced: " + descrizione);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
GWT.log("error: " + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
// GeoportalDataViewerConstants.print("1: "+descrizione);
|
|
|
|
|
flex.setText(1, 0, descrizione);
|
|
|
|
|
// GeoportalDataViewerConstants.print("2: "+date);
|
|
|
|
|
date = StringUtil.formatDate(date);
|
|
|
|
|
flex.setHTML(2, 0, new HTML("<code>" + date + "</code>").toString());
|
|
|
|
|
|
|
|
|
|
if (geoNaDataObject.getMapImages() != null) {
|
|
|
|
|
for (String key : geoNaDataObject.getMapImages().keySet()) {
|
|
|
|
|
List<UploadedImageDV> listUI = geoNaDataObject.getMapImages().get(key);
|
|
|
|
|
GWT.log("Adding images: " + listUI);
|
|
|
|
|
if (listUI != null && listUI.size() > 0) {
|
|
|
|
|
UploadedImageDV img = listUI.get(0);
|
|
|
|
|
if (img.getListWsContent() != null) {
|
|
|
|
|
WorkspaceContentDV wsContent = img.getListWsContent().get(img.getListWsContent().size() - 1);
|
|
|
|
|
String theImgHTML = "<img src=\"" + wsContent.getLink() + "\"></img>";
|
|
|
|
|
GWT.log("theImgHTML: " + theImgHTML);
|
|
|
|
|
// GeoportalDataViewerConstants.print("The row are:
|
|
|
|
|
// "+flex.getRowCount());
|
|
|
|
|
flex.setHTML(flex.getRowCount() + 1, 0, theImgHTML);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GWT.log("The selected Feature is: " + feature);
|
|
|
|
|
// GeoportalDataViewerConstants.print("The selected Feature is: "+feature);
|
|
|
|
|
FeatureRow theFeature = feature;
|
|
|
|
|
Button button = new Button("Open Details");
|
|
|
|
|
button.getElement().setId("open-details");
|
|
|
|
|
button.setType(ButtonType.LINK);
|
|
|
|
|
|
|
|
|
|
if (button != null) {
|
|
|
|
|
vpPanel.add(button);
|
|
|
|
|
button.setType(ButtonType.LINK);
|
|
|
|
|
button.addClickHandler(new ClickHandler() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(ClickEvent event) {
|
|
|
|
|
ShowDetailsEvent toEvent = parseGeonaReferences(
|
|
|
|
|
geoNaDataObject.getSourceLayerObject().getItemType(), theFeature);
|
|
|
|
|
applicationBus.fireEvent(toEvent);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Coordinate centerTo = null;
|
|
|
|
|
GWT.log("geometry is: " + feature.getGeometry());
|
|
|
|
|
if (feature.getGeometry() != null) {
|
|
|
|
|
GWT.log("trasforming geometry: " + feature.getGeometry().getToJSONObject());
|
|
|
|
|
|
|
|
|
|
Geometry geom = new GeoJson().readGeometry(feature.getGeometry().getToJSONObject(), null);
|
|
|
|
|
|
|
|
|
|
// POINT
|
|
|
|
|
if (geom.getType().equalsIgnoreCase("Point")) {
|
|
|
|
|
GWT.log("geometry: is a point");
|
|
|
|
|
String coordinateJSON = feature.getGeometry().getCoordinatesJSON();
|
|
|
|
|
JSONArray centerJSON = (JSONArray) JSONParser.parseStrict(coordinateJSON);
|
|
|
|
|
// Coordinate center = OLFactory.createCoordinate(
|
|
|
|
|
// new Double(centerJSON.get(0).toString()),
|
|
|
|
|
// new Double(centerJSON.get(1).toString()));
|
|
|
|
|
|
|
|
|
|
Coordinate center = new Coordinate(new Double(centerJSON.get(0).toString()),
|
|
|
|
|
new Double(centerJSON.get(1).toString()));
|
|
|
|
|
|
|
|
|
|
if (feature.getCrsName() != null && feature.getCrsName().endsWith(MAP_PROJECTION.EPSG_4326.getId())) {
|
|
|
|
|
|
|
|
|
|
center = MapUtils.transformCoordiante(center, MAP_PROJECTION.EPSG_4326.getName(),
|
|
|
|
|
MAP_PROJECTION.EPSG_3857.getName());
|
|
|
|
|
}
|
|
|
|
|
centerTo = center;
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
Extent geomExtent = geom.getExtent();
|
|
|
|
|
|
|
|
|
|
Coordinate lower = OLFactory.createCoordinate(geomExtent.getLowerLeftX(), geomExtent.getLowerLeftY());
|
|
|
|
|
Coordinate upper = OLFactory.createCoordinate(geomExtent.getUpperRightX(), geomExtent.getUpperRightY());
|
|
|
|
|
Coordinate lowerCoord = lower;
|
|
|
|
|
Coordinate upperCoord = upper;
|
|
|
|
|
if (feature.getCrsName() != null && feature.getCrsName().endsWith(MAP_PROJECTION.EPSG_4326.getId())) {
|
|
|
|
|
|
|
|
|
|
lowerCoord = MapUtils.transformCoordiante(lower, MAP_PROJECTION.EPSG_4326.getName(),
|
|
|
|
|
MAP_PROJECTION.EPSG_3857.getName());
|
|
|
|
|
upperCoord = MapUtils.transformCoordiante(upper, MAP_PROJECTION.EPSG_4326.getName(),
|
|
|
|
|
MAP_PROJECTION.EPSG_3857.getName());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ExtentWrapped ew = new ExtentWrapped(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(),
|
|
|
|
|
upperCoord.getY());
|
|
|
|
|
|
|
|
|
|
centerTo = new Coordinate(ew.getCenter().getX(), ew.getCenter().getY());
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
GWT.log("center is: " + centerTo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// fallback
|
|
|
|
|
if (centerTo == null)
|
|
|
|
|
centerTo = onFailureCenterTo;
|
|
|
|
|
|
|
|
|
|
olMap.showPopup(vpPanel.toString(), centerTo);
|
|
|
|
|
|
|
|
|
|
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void execute() {
|
|
|
|
|
Element buttonElement = DOM.getElementById("open-details");
|
|
|
|
|
Event.sinkEvents(buttonElement, Event.ONCLICK);
|
|
|
|
|
Event.setEventListener(buttonElement, new EventListener() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onBrowserEvent(Event event) {
|
|
|
|
|
if (Event.ONCLICK == event.getTypeInt()) {
|
|
|
|
|
ShowDetailsEvent toEvent = parseGeonaReferences(
|
|
|
|
|
geoNaDataObject.getSourceLayerObject().getItemType(), theFeature);
|
|
|
|
|
applicationBus.fireEvent(toEvent);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Checks if is layer visible.
|
|
|
|
|
*
|
|
|
|
|