fixed css. managing popup info separately

task_21890
Francesco Mangiacrapa 3 years ago
parent 0e082c0c37
commit 2af0252338

@ -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.
*

@ -191,7 +191,7 @@ public class GeonaDataViewMainPanel extends Composite {
@Override
public void onClick(ClickEvent event) {
Location earthLocation = ExtentMapUtil.getLocation(ExtentMapUtil.PLACE.EARTH);
Location earthLocation = ExtentMapUtil.getLocation(ExtentMapUtil.PLACE.WORLD);
applicationBus.fireEvent(new MapExtentToEvent(earthLocation));
map.setCenter(earthLocation.getCoordinate(MAP_PROJECTION.EPSG_3857));
map.setZoom(earthLocation.getZoomLevel());

@ -27,7 +27,7 @@ public class ExtentMapUtil {
* Sep 1, 2021
*/
public static enum PLACE {
ITALY, EARTH
ITALY, WORLD
}
final static Map<PLACE, Location> mapExtent = new HashMap<PLACE, Location>();
@ -39,13 +39,13 @@ public class ExtentMapUtil {
GeoportalDataViewerConstants.ITALY_CENTER_LAT, MAP_PROJECTION.EPSG_4326,
GeoportalDataViewerConstants.MAP_ITALY_FIT_ZOOM_ON);
// EPSG_4326 EARTH LOCATION
Location earth = new Location(PLACE.EARTH.name(), 0,
// EPSG_4326 WORLD LOCATION
Location earth = new Location(PLACE.WORLD.name(), 0,
0, MAP_PROJECTION.EPSG_4326,
2);
mapExtent.put(PLACE.ITALY, ita);
mapExtent.put(PLACE.EARTH, earth);
mapExtent.put(PLACE.WORLD, earth);
}

@ -61,7 +61,7 @@ public class LayerConcessioneView extends Composite {
exportMapButton.setIcon(IconType.DOWNLOAD_ALT);
exportMapButton.setTitle("Export the map view (OSM + layer) as an image...");
Style exportStyle = exportMapButton.getElement().getStyle();
exportStyle.setWidth(100, Unit.PCT);
//exportStyle.setWidth(100, Unit.PCT);
exportStyle.setMarginLeft(70, Unit.PCT);
Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY);

Loading…
Cancel
Save