implementing task #21946

This commit is contained in:
Francesco Mangiacrapa 2021-08-31 18:21:17 +02:00
parent 97db5d2c12
commit b2e6830bbe
12 changed files with 534 additions and 224 deletions

View File

@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
[#21890] Porting to ConcessioniManagerI and pass to mongoID [#21890] Porting to ConcessioniManagerI and pass to mongoID
[#20595] Porting and using the model view provided by geoportal-common [#20595] Porting and using the model view provided by geoportal-common
[#21946] Show layers of a concessione automatically on map according to zoom level
## [v1.2.0-SNAPSHOT] - 2021-07-19 ## [v1.2.0-SNAPSHOT] - 2021-07-19

View File

@ -7,6 +7,11 @@ The GeoPortal Data Viewer App is an application to access, discovery and navigat
* [OpenJDK](https://openjdk.java.net/) - The JDK used * [OpenJDK](https://openjdk.java.net/) - The JDK used
* [Maven](https://maven.apache.org/) - Dependency Management * [Maven](https://maven.apache.org/) - Dependency Management
** Uses **
* [GWT-OL3](https://github.com/TDesjardins/gwt-ol) GWT-OpenLayers 3+ v.8.0.0-gwt2_9
* [OpenLayers](https://openlayers.org/) OpenLayers v.6.X
## Documentation ## Documentation
N/A N/A

View File

@ -7,6 +7,7 @@ import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
import org.gcube.application.geoportalcommon.shared.LayerItem; import org.gcube.application.geoportalcommon.shared.LayerItem;
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV; import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.model.RecordDV; import org.gcube.application.geoportalcommon.shared.products.model.RecordDV;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MapEventType;
import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEventHandler; import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ClosedViewDetailsEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.ClosedViewDetailsEvent;
@ -167,7 +168,7 @@ public class GeoportalDataViewer implements EntryPoint {
GWT.log("The layerItem is: " + layerItem); GWT.log("The layerItem is: " + layerItem);
layerManager.addLayer(theItemType, null, null, layerItem.getWmsLink(), false, false, layerManager.addLayer(theItemType, null, null, layerItem.getWmsLink(), false, false,
null, true); null, false);
if (paramGeonaItemID != null) { if (paramGeonaItemID != null) {
if (paramGeonaItemType == null) { if (paramGeonaItemType == null) {
@ -308,6 +309,7 @@ public class GeoportalDataViewer implements EntryPoint {
if(mainPanel.getDisplyedRecord()==null && !olMapMng.isQueryPointActive()) { if(mainPanel.getDisplyedRecord()==null && !olMapMng.isQueryPointActive()) {
olMapMng.hidePopInfo(); olMapMng.hidePopInfo();
olMapMng.removeDetailLayers();
} }
} }
@ -337,7 +339,7 @@ public class GeoportalDataViewer implements EntryPoint {
GeoQuery select = olMapMng.toDataPointQuery(transfCoord,false); GeoQuery select = olMapMng.toDataPointQuery(transfCoord,false);
GWT.log("GeoQuery: "+select); GWT.log("GeoQuery: "+select);
//GeoportalDataViewerConstants.print("fireEvent QueryDataEvent"); //GeoportalDataViewerConstants.print("fireEvent QueryDataEvent");
layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, transfCoord, record.getItemId(), true)); layerManager.getLayerManagerBus().fireEvent(new QueryDataEvent(select, transfCoord, record.getItemId(), true, MapEventType.ADDED_LAYER_TO_MAP));
}else { }else {
GeoportalDataViewerConstants.printJs("I cannot select the point one or both coordiantes are null. X: "+x +", Y:"+y); GeoportalDataViewerConstants.printJs("I cannot select the point one or both coordiantes are null. X: "+x +", Y:"+y);
} }

View File

@ -28,6 +28,8 @@ public class GeoportalDataViewerConstants {
public static final String GET_ZOOM = OpenLayersMapParameters.OL_MAP_PARAM.zoom.name(); public static final String GET_ZOOM = OpenLayersMapParameters.OL_MAP_PARAM.zoom.name();
public static final String GET_CENTER_MAP_TO_LONG_LAT = OpenLayersMapParameters.OL_MAP_PARAM.centermap.name(); public static final String GET_CENTER_MAP_TO_LONG_LAT = OpenLayersMapParameters.OL_MAP_PARAM.centermap.name();
public static enum MapEventType {INIT, MAP_ZOOM_END, MOVE_END, ADDED_LAYER_TO_MAP}
/** /**
* The Enum LayerType. * The Enum LayerType.
* *

View File

@ -111,4 +111,17 @@ public interface GeoportalDataViewerService extends RemoteService {
*/ */
List<LayerConcessioneDV> getLayersForId(String itemType, String itemId) throws Exception; List<LayerConcessioneDV> getLayersForId(String itemType, String itemId) throws Exception;
/**
* Gets the WFS features.
*
* @param layerObjects the layer objects
* @param mapSrsName the map srs name
* @param selectBBOX the select BBOX
* @param maxWFSFeature the max WFS feature
* @param zoomLevel the zoom level
* @return the WFS features
*/
List<GeoNaSpatialQueryResult> getWFSFeatures(List<LayerObject> layerObjects, String mapSrsName,
BoundsMap selectBBOX, int maxWFSFeature, double zoomLevel);
} }

View File

@ -54,4 +54,7 @@ public interface GeoportalDataViewerServiceAsync {
void getLayersForId(String itemType, String itemId, void getLayersForId(String itemType, String itemId,
AsyncCallback<List<LayerConcessioneDV>> asyncCallback); AsyncCallback<List<LayerConcessioneDV>> asyncCallback);
void getWFSFeatures(List<LayerObject> layerObjects, String mapSrsName, BoundsMap selectBBOX, int maxWFSFeature,
double zoomLevel, AsyncCallback<List<GeoNaSpatialQueryResult>> callback);
} }

View File

@ -10,8 +10,10 @@ import java.util.Map;
import org.gcube.application.geoportalcommon.shared.gis.BoundsMap; import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV; import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV;
import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV; import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.LayerType; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.LayerType;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MapEventType;
import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEventHandler; import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEventHandler;
import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEvent;
@ -63,7 +65,7 @@ public class LayerManager {
/** The ol map. */ /** The ol map. */
private OpenLayerOSM olMap; private OpenLayerOSM olMap;
private List<LayerObject> layerObjects = new ArrayList<LayerObject>(); private Map<String, LayerObject> layerObjects = new HashMap<String, LayerObject>();
private HandlerManager layerManagerBus = new HandlerManager(""); private HandlerManager layerManagerBus = new HandlerManager("");
@ -98,7 +100,7 @@ public class LayerManager {
GWT.log("(" + selectDataInfo.getX1() + "," + selectDataInfo.getY1() + ")(" + selectDataInfo.getX2() GWT.log("(" + selectDataInfo.getX1() + "," + selectDataInfo.getY1() + ")(" + selectDataInfo.getX2()
+ "," + selectDataInfo.getY2() + ")"); + "," + selectDataInfo.getY2() + ")");
for (LayerObject layerObj : layerObjects) { for (LayerObject layerObj : layerObjects.values()) {
// TODO // TODO
isLayerVisible(layerObj.getLayerItem()); isLayerVisible(layerObj.getLayerItem());
@ -141,10 +143,10 @@ public class LayerManager {
GWT.log("Bounds is: " + mapBBOX); GWT.log("Bounds is: " + mapBBOX);
GWT.log("MAX_WFS_FEATURES is: " + GeoportalDataViewerConstants.MAX_WFS_FEATURES); GWT.log("MAX_WFS_FEATURES is: " + GeoportalDataViewerConstants.MAX_WFS_FEATURES);
// GeoportalDataViewerConstants.print("calling getDataResult"); // GeoportalDataViewerConstants.print("calling getDataResult");
List<LayerObject> listLO = new ArrayList<LayerObject>(layerObjects.values());
GeoportalDataViewerServiceAsync.Util.getInstance().getDataResult(layerObjects, GeoportalDataViewerServiceAsync.Util.getInstance().getDataResult(listLO, olMap.getProjectionCode(),
olMap.getProjectionCode(), mapBBOX, GeoportalDataViewerConstants.MAX_WFS_FEATURES, mapBBOX, GeoportalDataViewerConstants.MAX_WFS_FEATURES, olMap.getCurrentZoomLevel(),
olMap.getCurrentZoomLevel(), new AsyncCallback<List<GeoNaSpatialQueryResult>>() { new AsyncCallback<List<GeoNaSpatialQueryResult>>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
@ -169,7 +171,7 @@ public class LayerManager {
flex.getElement().addClassName("popup-table"); flex.getElement().addClassName("popup-table");
boolean featureFound = false; boolean featureFound = false;
FeatureRow feature = null; FeatureRow feature = null;
// TODO SWTCH FOR EARCH ITEM TYPE // TODO SWTCH FOR EARCH ITEM TYPE
for (GeoNaSpatialQueryResult geoNaDataObject : listGeonaDataObjects) { for (GeoNaSpatialQueryResult geoNaDataObject : listGeonaDataObjects) {
List<FeatureRow> features = geoNaDataObject.getFeatures(); List<FeatureRow> features = geoNaDataObject.getFeatures();
@ -184,7 +186,7 @@ public class LayerManager {
.get("product_id"); .get("product_id");
theProductId = productIdLst.get(0); theProductId = productIdLst.get(0);
try { try {
//long productId = Long.parseLong(thePID); // long productId = Long.parseLong(thePID);
if (theProductId == mongoItemId) { if (theProductId == mongoItemId) {
feature = fRow; feature = fRow;
GWT.log("Found recorId == product_id with id: " GWT.log("Found recorId == product_id with id: "
@ -202,6 +204,12 @@ public class LayerManager {
feature = features.get(0); feature = features.get(0);
List<String> productIdLst = feature.getMapProperties() List<String> productIdLst = feature.getMapProperties()
.get("product_id"); .get("product_id");
if (productIdLst == null) {
// in this case the feature returned is a (detail) layer belonging
// to a record/concessione (not centroid layer),
// so returning
return;
}
theProductId = productIdLst.get(0); theProductId = productIdLst.get(0);
} else { } else {
// the recordId to show has been passed but not found into list of // the recordId to show has been passed but not found into list of
@ -210,36 +218,48 @@ public class LayerManager {
return; return;
} }
} }
GWT.log("the product id is: "+theProductId);
/*if(olMap.getCurrentZoomLevel()>10) {
GeoportalDataViewerServiceAsync.Util.getInstance().getLayersForId("concessione", theProductId, new AsyncCallback<List<LayerConcessioneDV>>() {
@Override GWT.log("the product id is: " + theProductId);
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
}
@Override // retrieving and showing WMS layers of a concessione if the ZOOM level is > QUERY_MIN_ZOOM_LEVEL
public void onSuccess(List<LayerConcessioneDV> result) { if (olMap.getCurrentZoomLevel() > OLMapManager.QUERY_MIN_ZOOM_LEVEL) {
GWT.log("Adding layers: "+result); GeoportalDataViewerServiceAsync.Util.getInstance().getLayersForId(
for (LayerConcessioneDV layer : result) { "concessione", theProductId,
addLayer("concessione", layer.getLayerName(), layer.getLayerName(), layer.getWmsLink(), false, false, layer.getLayerUUID(), true); new AsyncCallback<List<LayerConcessioneDV>>() {
@Override
public void onFailure(Throwable caught) {
// TODO Auto-generated method stub
}
@Override
public void onSuccess(List<LayerConcessioneDV> result) {
GWT.log("Adding layers: " + result);
for (LayerConcessioneDV layer : result) {
addLayer("concessione", layer.getLayerName(),
layer.getLayerName(), layer.getWmsLink(),
false, false, layer.getLayerUUID(), true);
// LayerItem li = new LayerItem(); // LayerItem li = new LayerItem();
// li.setBaseLayer(false); // li.setBaseLayer(false);
// li.setWmsLink(layer.getWmsLink()); // li.setWmsLink(layer.getWmsLink());
// li.setTitle(layer.getLayerName()); // li.setTitle(layer.getLayerName());
// olMap.addWMSLayer(li); // olMap.addWMSLayer(li);
} }
}
});
return;
}*/
}
});
} else {
// removing all WMS detail layers if the ZOOM level is < QUERY_MIN_ZOOM_LEVEL
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(); Map<String, List<String>> entries = feature.getMapProperties();
String nome = ""; String nome = "";
@ -433,11 +453,11 @@ public class LayerManager {
* @param isBase the is base * @param isBase the is base
* @param displayInLayerSwitcher the display in layer switcher * @param displayInLayerSwitcher the display in layer switcher
* @param UUID the uuid * @param UUID the uuid
* @param onTop the on top * @param asDetailLayer the as detail layer
*/ */
public void addLayer(final String geonaItemType, final String layerTitle, final String layerName, public void addLayer(final String geonaItemType, final String layerTitle, final String layerName,
final String wmsLink, final boolean isBase, final boolean displayInLayerSwitcher, final String UUID, final String wmsLink, final boolean isBase, final boolean displayInLayerSwitcher, final String UUID,
final boolean onTop) { final boolean asDetailLayer) {
// final LayoutContainer westPanel = (LayoutContainer) layersPanel.getParent(); // final LayoutContainer westPanel = (LayoutContainer) layersPanel.getParent();
// //
@ -448,6 +468,12 @@ public class LayerManager {
final LayerType featureType = isBase ? LayerType.RASTER_BASELAYER : LayerType.FEATURE_TYPE; final LayerType featureType = isBase ? LayerType.RASTER_BASELAYER : LayerType.FEATURE_TYPE;
// Info.display("Adding Layer", layerName); // Info.display("Adding Layer", layerName);
if(wmsLink==null || wmsLink.isEmpty()) {
GeoportalDataViewerConstants.printJs("Skipping add layer for wmsLink as null or empty");
return;
}
GeoportalDataViewerServiceAsync.Util.getInstance().parseWmsRequest(wmsLink, layerName, GeoportalDataViewerServiceAsync.Util.getInstance().parseWmsRequest(wmsLink, layerName,
new AsyncCallback<GeoInformationForWMSRequest>() { new AsyncCallback<GeoInformationForWMSRequest>() {
@ -475,8 +501,19 @@ public class LayerManager {
LayerObject lo = new LayerObject(); LayerObject lo = new LayerObject();
lo.setLayerItem(layerItem); lo.setLayerItem(layerItem);
lo.setItemType(geonaItemType); lo.setItemType(geonaItemType);
layerObjects.add(lo);
olMap.addWMSLayer(layerItem); String key = layerItem.getMapServerHost() + "/layer/" + layerItem.getName();
// //if a detail layer checking if it is already added to map
// if (asDetailLayer && layerObjects.containsKey(key)) {
// GWT.log("Skipping layer already added to Map");
// } else {
layerObjects.put(key, lo);
if (!asDetailLayer)
olMap.addWMSLayer(layerItem);
else
olMap.addWMSDetailLayer(layerItem);
// }
} }
}); });
} }

View File

@ -1,5 +1,6 @@
package org.gcube.portlets.user.geoportaldataviewer.client; package org.gcube.portlets.user.geoportaldataviewer.client;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MapEventType;
import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMinimumEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMinimumEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped; import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped;
@ -21,7 +22,7 @@ import ol.OLFactory;
* *
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* *
* Nov 19, 2020 * Nov 19, 2020
*/ */
public class OLMapManager { public class OLMapManager {
@ -32,12 +33,12 @@ public class OLMapManager {
private Double zoomStart = null; private Double zoomStart = null;
private Double zoomEnd = null; private Double zoomEnd = null;
private ol.Extent dragEndExtent = null; private ol.Extent dragEndExtent = null;
private static final int QUERY_MIN_ZOOM_LEVEL = 13; public static final int QUERY_MIN_ZOOM_LEVEL = 13;
/** /**
* Instantiates a new OL map manager. * Instantiates a new OL map manager.
* *
* @param targetId the target id * @param targetId the target id
* @param layerManagerBus the layer manager bus * @param layerManagerBus the layer manager bus
*/ */
public OLMapManager(String targetId, HandlerManager layerManagerBus) { public OLMapManager(String targetId, HandlerManager layerManagerBus) {
@ -56,64 +57,64 @@ public class OLMapManager {
@Override @Override
public void clickListener(MapBrowserEvent event) { public void clickListener(MapBrowserEvent event) {
Coordinate coordinate = event.getCoordinate(); Coordinate coordinate = event.getCoordinate();
if(!olMap.mapInstancied()) if (!olMap.mapInstancied())
return; return;
// if (olMap.isQueryPointActive()) { // if (olMap.isQueryPointActive()) {
// GeoQuery select = toDataPointQuery(coordinate); // GeoQuery select = toDataPointQuery(coordinate);
// layerManagerBus.fireEvent(new QueryDataEvent(select, coordinate)); // layerManagerBus.fireEvent(new QueryDataEvent(select, coordinate));
// //
// } // }
GeoQuery select = toDataPointQuery(coordinate,true); GeoQuery select = toDataPointQuery(coordinate, true);
layerManagerBus.fireEvent(new QueryDataEvent(select, coordinate, null, true)); layerManagerBus.fireEvent(new QueryDataEvent(select, coordinate, null, true, MapEventType.INIT));
} }
@Override @Override
public void moveEndListener(MapEvent event) { public void moveEndListener(MapEvent event) {
//onInit // onInit
if(!olMap.mapInstancied()) if (!olMap.mapInstancied())
return; return;
checkSelectQuery(); checkSelectQuery(MapEventType.MOVE_END);
} }
@Override @Override
public void moveStartListener(MapEvent event) { public void moveStartListener(MapEvent event) {
//onInit // onInit
if(!olMap.mapInstancied()) if (!olMap.mapInstancied())
return; return;
setDragStart(); setDragStart();
} }
@Override @Override
public void mapZoomListener(MapEvent event) { public void mapZoomListener(MapEvent event) {
//onInit // onInit
if(!olMap.mapInstancied()) if (!olMap.mapInstancied())
return; return;
setDragStart(); setDragStart();
zoomStart = olMap.getCurrentZoomLevel(); zoomStart = olMap.getCurrentZoomLevel();
GWT.log("zoomStart: "+zoomStart); GWT.log("zoomStart: " + zoomStart);
} }
@Override @Override
public void mapZoomEndListener(MapEvent event) { public void mapZoomEndListener(MapEvent event) {
//onInit // onInit
if(!olMap.mapInstancied()) if (!olMap.mapInstancied())
return; return;
setDragStart(); setDragStart();
zoomEnd = olMap.getCurrentZoomLevel(); zoomEnd = olMap.getCurrentZoomLevel();
GWT.log("zoomEnd: "+zoomEnd); GWT.log("zoomEnd: " + zoomEnd);
checkSelectQuery(); checkSelectQuery(MapEventType.MAP_ZOOM_END);
} }
@ -140,7 +141,7 @@ public class OLMapManager {
double lon = coordinate.getX(); double lon = coordinate.getX();
double lat = coordinate.getY(); double lat = coordinate.getY();
GWT.log("To quey DP: "+coordinate); GWT.log("To quey DP: " + coordinate);
int w = (int) olMap.getSize().getWidth(); int w = (int) olMap.getSize().getWidth();
int h = (int) olMap.getSize().getHeight(); int h = (int) olMap.getSize().getHeight();
@ -150,16 +151,15 @@ public class OLMapManager {
// where 10px is the pixel diameter dimension of the clicked point // where 10px is the pixel diameter dimension of the clicked point
double bboxWidth = Math.abs(olMap.getExtent().getLowerLeftX() - olMap.getExtent().getUpperRightX()); double bboxWidth = Math.abs(olMap.getExtent().getLowerLeftX() - olMap.getExtent().getUpperRightX());
double geoWidth = 0; double geoWidth = 0;
//adding a tolerance in case of manual click // adding a tolerance in case of manual click
if(manualClick) { if (manualClick) {
//adding a tolerance for clicking // adding a tolerance for clicking
geoWidth = (bboxWidth / w) * (14 / 2); geoWidth = (bboxWidth / w) * (14 / 2);
} } else {
else { // data point selection for coordinate loaded from concessione
//data point selection for coordinate loaded from concessione
geoWidth = (bboxWidth / w) * (2); geoWidth = (bboxWidth / w) * (2);
} }
double x1 = Math.min(lon + geoWidth, lon - geoWidth); double x1 = Math.min(lon + geoWidth, lon - geoWidth);
double x2 = Math.max(lon + geoWidth, lon - geoWidth); double x2 = Math.max(lon + geoWidth, lon - geoWidth);
double y1 = Math.min(lat + geoWidth, lat - geoWidth); double y1 = Math.min(lat + geoWidth, lat - geoWidth);
@ -182,8 +182,8 @@ public class OLMapManager {
/** /**
* Check select query. * Check select query.
*/ */
private void checkSelectQuery() { private void checkSelectQuery(MapEventType mapEventType) {
GWT.log("Zoom is:" + olMap.getCurrentZoomLevel()); GWT.log("Zoom is:" + olMap.getCurrentZoomLevel());
if (dragStartExtent != null && olMap.getCurrentZoomLevel() > QUERY_MIN_ZOOM_LEVEL) { if (dragStartExtent != null && olMap.getCurrentZoomLevel() > QUERY_MIN_ZOOM_LEVEL) {
@ -199,12 +199,11 @@ public class OLMapManager {
GWT.log("the distance is: " + dist); GWT.log("the distance is: " + dist);
if (dist > 5000 || startExt.containsExtent(endExt)) { if (dist > 5000 || startExt.containsExtent(endExt)) {
GeoQuery select = toDataBoxQuery(dragEndExtent); GeoQuery select = toDataBoxQuery(dragEndExtent);
layerManagerBus.fireEvent(new QueryDataEvent(select, endExt.getCenter(), null, false)); layerManagerBus.fireEvent(new QueryDataEvent(select, endExt.getCenter(), null, false, mapEventType));
} }
} } else if (zoomStart != null && zoomEnd != null) {
else if(zoomStart!=null && zoomEnd!=null) {
if (zoomEnd < QUERY_MIN_ZOOM_LEVEL) {
if(zoomEnd<QUERY_MIN_ZOOM_LEVEL) {
layerManagerBus.fireEvent(new ZoomOutOverMinimumEvent(zoomStart, zoomEnd, QUERY_MIN_ZOOM_LEVEL)); layerManagerBus.fireEvent(new ZoomOutOverMinimumEvent(zoomStart, zoomEnd, QUERY_MIN_ZOOM_LEVEL));
} }
} }
@ -220,7 +219,7 @@ public class OLMapManager {
GWT.log("Drag Start is: " + dragStartExtent); GWT.log("Drag Start is: " + dragStartExtent);
} }
} }
/** /**
* To data point query. * To data point query.
* *
@ -228,11 +227,11 @@ public class OLMapManager {
* @return the geo query * @return the geo query
*/ */
private GeoQuery toDataBoxQuery(ol.Extent extent) { private GeoQuery toDataBoxQuery(ol.Extent extent) {
return new GeoQuery(extent.getLowerLeftX(), extent.getLowerLeftY(), extent.getUpperRightX(), extent.getUpperRightY(), TYPE.BOX); return new GeoQuery(extent.getLowerLeftX(), extent.getLowerLeftY(), extent.getUpperRightX(),
extent.getUpperRightY(), TYPE.BOX);
} }
/** /**
* Checks if is query point active. * Checks if is query point active.
* *
@ -248,6 +247,12 @@ public class OLMapManager {
public void hidePopInfo() { public void hidePopInfo() {
olMap.hidePopup(); olMap.hidePopup();
} }
/**
* Removes the detail layers.
*/
public void removeDetailLayers() {
olMap.removeAllDetailLayers();
}
} }

View File

@ -1,5 +1,6 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events; package org.gcube.portlets.user.geoportaldataviewer.client.events;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MapEventType;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery;
import com.google.gwt.event.shared.GwtEvent; import com.google.gwt.event.shared.GwtEvent;
@ -9,9 +10,9 @@ import ol.Coordinate;
/** /**
* The Class QueryDataEvent. * The Class QueryDataEvent.
* *
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
* *
* Oct 29, 2020 * Aug 31, 2021
*/ */
public class QueryDataEvent extends GwtEvent<QueryDataEventHandler> { public class QueryDataEvent extends GwtEvent<QueryDataEventHandler> {
public static Type<QueryDataEventHandler> TYPE = new Type<QueryDataEventHandler>(); public static Type<QueryDataEventHandler> TYPE = new Type<QueryDataEventHandler>();
@ -19,6 +20,7 @@ public class QueryDataEvent extends GwtEvent<QueryDataEventHandler> {
private Coordinate onFailureCenterTo; private Coordinate onFailureCenterTo;
private String mongoItemId; private String mongoItemId;
private boolean onInit; private boolean onInit;
private MapEventType sourceMapEventType;
/** /**
* Instantiates a new query data event. * Instantiates a new query data event.
@ -27,12 +29,15 @@ public class QueryDataEvent extends GwtEvent<QueryDataEventHandler> {
* @param onFailureCenterTo the on failure center to * @param onFailureCenterTo the on failure center to
* @param mongoItemId the mongo item id * @param mongoItemId the mongo item id
* @param onInit the on init * @param onInit the on init
* @param mapEventType the map event type
*/ */
public QueryDataEvent(GeoQuery select, Coordinate onFailureCenterTo, String mongoItemId, boolean onInit) { public QueryDataEvent(GeoQuery select, Coordinate onFailureCenterTo, String mongoItemId, boolean onInit,
MapEventType mapEventType) {
this.select = select; this.select = select;
this.onFailureCenterTo = onFailureCenterTo; this.onFailureCenterTo = onFailureCenterTo;
this.mongoItemId = mongoItemId; this.mongoItemId = mongoItemId;
this.onInit = onInit; this.onInit = onInit;
this.sourceMapEventType = mapEventType;
} }
/** /**
@ -45,6 +50,11 @@ public class QueryDataEvent extends GwtEvent<QueryDataEventHandler> {
return TYPE; return TYPE;
} }
/**
* Gets the mongo item id.
*
* @return the mongo item id
*/
public String getMongoItemId() { public String getMongoItemId() {
return mongoItemId; return mongoItemId;
} }
@ -78,10 +88,29 @@ public class QueryDataEvent extends GwtEvent<QueryDataEventHandler> {
return select; return select;
} }
/**
* Gets the on failure center to.
*
* @return the on failure center to
*/
public Coordinate getOnFailureCenterTo() { public Coordinate getOnFailureCenterTo() {
return onFailureCenterTo; return onFailureCenterTo;
} }
/**
* Gets the source map event type.
*
* @return the source map event type
*/
public MapEventType getSourceMapEventType() {
return sourceMapEventType;
}
/**
* To string.
*
* @return the string
*/
@Override @Override
public String toString() { public String toString() {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
@ -93,6 +122,8 @@ public class QueryDataEvent extends GwtEvent<QueryDataEventHandler> {
builder.append(mongoItemId); builder.append(mongoItemId);
builder.append(", onInit="); builder.append(", onInit=");
builder.append(onInit); builder.append(onInit);
builder.append(", sourceMapEventType=");
builder.append(sourceMapEventType);
builder.append("]"); builder.append("]");
return builder.toString(); return builder.toString();
} }

View File

@ -1,5 +1,7 @@
package org.gcube.portlets.user.geoportaldataviewer.client.gis; package org.gcube.portlets.user.geoportaldataviewer.client.gis;
import java.util.HashMap;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants; import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent; import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem; import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
@ -13,6 +15,8 @@ import com.google.gwt.user.client.Event;
import ol.Collection; import ol.Collection;
import ol.Coordinate; import ol.Coordinate;
import ol.Feature;
import ol.FeatureOptions;
import ol.Map; import ol.Map;
import ol.MapBrowserEvent; import ol.MapBrowserEvent;
import ol.MapEvent; import ol.MapEvent;
@ -25,6 +29,7 @@ import ol.View;
import ol.ViewOptions; import ol.ViewOptions;
import ol.control.Attribution; import ol.control.Attribution;
import ol.event.EventListener; import ol.event.EventListener;
import ol.geom.Geometry;
import ol.interaction.Draw; import ol.interaction.Draw;
import ol.interaction.DrawOptions; import ol.interaction.DrawOptions;
import ol.interaction.Extent; import ol.interaction.Extent;
@ -36,6 +41,7 @@ import ol.layer.Base;
import ol.layer.Image; import ol.layer.Image;
import ol.layer.LayerOptions; import ol.layer.LayerOptions;
import ol.layer.Tile; import ol.layer.Tile;
import ol.layer.VectorLayerOptions;
import ol.proj.Projection; import ol.proj.Projection;
import ol.proj.ProjectionOptions; import ol.proj.ProjectionOptions;
import ol.source.ImageWms; import ol.source.ImageWms;
@ -45,74 +51,101 @@ import ol.source.Osm;
import ol.source.Vector; import ol.source.Vector;
import ol.source.XyzOptions; import ol.source.XyzOptions;
// TODO: Auto-generated Javadoc // TODO: Auto-generated Javadoc
/** /**
* The Class OpenLayerOSM. * The Class OpenLayerOSM.
* *
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it) * @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
* *
* Oct 27, 2020 * Oct 27, 2020
*/ */
public abstract class OpenLayerOSM { public abstract class OpenLayerOSM {
/**
* Click listener.
*
* @param event the event
*/
public abstract void clickListener(MapBrowserEvent event); public abstract void clickListener(MapBrowserEvent event);
/**
* Move end listener.
*
* @param event the event
*/
public abstract void moveEndListener(MapEvent event); public abstract void moveEndListener(MapEvent event);
/**
* Move start listener.
*
* @param event the event
*/
public abstract void moveStartListener(MapEvent event); public abstract void moveStartListener(MapEvent event);
/**
* Map zoom listener.
*
* @param event the event
*/
public abstract void mapZoomListener(MapEvent event); public abstract void mapZoomListener(MapEvent event);
/**
* Map zoom end listener.
*
* @param event the event
*/
public abstract void mapZoomEndListener(MapEvent event); public abstract void mapZoomEndListener(MapEvent event);
/** The map. */ /** The map. */
private Map map; private Map map;
/** The view. */ /** The view. */
private View view; private View view;
/** The view options. */ /** The view options. */
private ViewOptions viewOptions = OLFactory.createOptions(); private ViewOptions viewOptions = OLFactory.createOptions();
/** The projection options. */ /** The projection options. */
private ProjectionOptions projectionOptions = OLFactory.createOptions(); private ProjectionOptions projectionOptions = OLFactory.createOptions();
/** The point draw. */ /** The point draw. */
private Draw queryPoint; private Draw queryPoint;
private Extent queryBox; private Extent queryBox;
/** The popup overlay. */ /** The popup overlay. */
private Overlay popupOverlay; private Overlay popupOverlay;
private HandlerManager eventBus; private HandlerManager eventBus;
private boolean isQueryBoxActive;
private boolean isQueryPointActive;
/** private boolean isQueryBoxActive;
* Instantiates a new open layer OSM.
* private boolean isQueryPointActive;
* @param divTargetId the div target id
* @param eventBus the event bus private java.util.Map<String, Image> wmsDetailsLayerMap;
*/
/* (non-Javadoc) /**
* @see de.desjardins.ol3.demo.client.example.Example#show() * Instantiates a new open layer OSM.
*/ *
* @param divTargetId the div target id
* @param eventBus the event bus
*/
/*
* (non-Javadoc)
*
* @see de.desjardins.ol3.demo.client.example.Example#show()
*/
public OpenLayerOSM(String divTargetId, HandlerManager eventBus) { public OpenLayerOSM(String divTargetId, HandlerManager eventBus) {
this.eventBus = eventBus; this.eventBus = eventBus;
// create a OSM-layer // create a OSM-layer
XyzOptions osmSourceOptions = OLFactory.createOptions(); XyzOptions osmSourceOptions = OLFactory.createOptions();
Osm osmSource = new Osm(osmSourceOptions); Osm osmSource = new Osm(osmSourceOptions);
LayerOptions osmLayerOptions = OLFactory.createOptions(); LayerOptions osmLayerOptions = OLFactory.createOptions();
osmLayerOptions.setSource(osmSource); osmLayerOptions.setSource(osmSource);
Tile osmLayer = new Tile(osmLayerOptions); Tile osmLayer = new Tile(osmLayerOptions);
// create a projection // create a projection
projectionOptions.setCode(GeoportalDataViewerConstants.EPSG_3857); projectionOptions.setCode(GeoportalDataViewerConstants.EPSG_3857);
projectionOptions.setUnits("m"); projectionOptions.setUnits("m");
@ -120,39 +153,41 @@ public abstract class OpenLayerOSM {
Projection projection = new Projection(projectionOptions); Projection projection = new Projection(projectionOptions);
viewOptions.setProjection(projection); viewOptions.setProjection(projection);
viewOptions.setMaxZoom(19); viewOptions.setMaxZoom(19);
// create a view // create a view
view = new View(viewOptions); view = new View(viewOptions);
// create the map
MapOptions mapOptions = OLFactory.createOptions();
mapOptions.setTarget(divTargetId);
mapOptions.setView(view);
map = new Map(mapOptions); // create the map
MapOptions mapOptions = OLFactory.createOptions();
mapOptions.setTarget(divTargetId);
mapOptions.setView(view);
map.addLayer(osmLayer); map = new Map(mapOptions);
//map.addLayer(tileDebugLayer);
// add some controls map.addLayer(osmLayer);
map.addControl(OLFactory.createScaleLine()); // map.addLayer(tileDebugLayer);
MapUtils.addDefaultControls(map.getControls());
Attribution attribution = new Attribution(); // add some controls
attribution.setCollapsed(true); map.addControl(OLFactory.createScaleLine());
map.addControl(attribution); MapUtils.addDefaultControls(map.getControls());
// add some interactions
map.addInteraction(new KeyboardPan());
map.addInteraction(new KeyboardZoom());
bindEvents();
} Attribution attribution = new Attribution();
attribution.setCollapsed(true);
map.addControl(attribution);
// add some interactions
map.addInteraction(new KeyboardPan());
map.addInteraction(new KeyboardZoom());
bindEvents();
}
/**
* Bind events.
*/
private void bindEvents() { private void bindEvents() {
map.addClickListener(new EventListener<MapBrowserEvent>() { map.addClickListener(new EventListener<MapBrowserEvent>() {
@Override @Override
@ -168,7 +203,7 @@ public abstract class OpenLayerOSM {
moveEndListener(event); moveEndListener(event);
} }
}); });
map.addMoveStartListener(new EventListener<MapEvent>() { map.addMoveStartListener(new EventListener<MapEvent>() {
@Override @Override
@ -176,7 +211,7 @@ public abstract class OpenLayerOSM {
moveStartListener(event); moveStartListener(event);
} }
}); });
map.addMapZoomListener(new EventListener<MapEvent>() { map.addMapZoomListener(new EventListener<MapEvent>() {
@Override @Override
@ -184,7 +219,7 @@ public abstract class OpenLayerOSM {
mapZoomListener(event); mapZoomListener(event);
} }
}); });
map.addMapZoomEndListener(new EventListener<MapEvent>() { map.addMapZoomEndListener(new EventListener<MapEvent>() {
@Override @Override
@ -193,32 +228,37 @@ public abstract class OpenLayerOSM {
} }
}); });
} }
/** /**
* Sets the center. * Sets the center.
* *
* @param centerCoordinate the new center * @param centerCoordinate the new center
*/ */
public void setCenter(Coordinate centerCoordinate) { public void setCenter(Coordinate centerCoordinate) {
view.setCenter(centerCoordinate); view.setCenter(centerCoordinate);
} }
/** /**
* Sets the center. * Sets the center.
* *
* @param centerCoordinate the new center * @param zoom the new zoom
*/ */
public void setZoom(int zoom) { public void setZoom(int zoom) {
view.setZoom(zoom); view.setZoom(zoom);
} }
/**
* Show popup.
*
* @param html the html
* @param coordinate the coordinate
*/
public void showPopup(String html, Coordinate coordinate) { public void showPopup(String html, Coordinate coordinate) {
GWT.log("Showing popup on: "+coordinate); GWT.log("Showing popup on: " + coordinate);
//GeoportalDataViewerConstants.print("Showing popup on: "+coordinate); // GeoportalDataViewerConstants.print("Showing popup on: "+coordinate);
Element elPopup = DOM.getElementById("popup"); Element elPopup = DOM.getElementById("popup");
elPopup.getStyle().setVisibility(Visibility.VISIBLE); elPopup.getStyle().setVisibility(Visibility.VISIBLE);
if(popupOverlay==null) { if (popupOverlay == null) {
popupOverlay = addOverlay(elPopup); popupOverlay = addOverlay(elPopup);
addPopupCloserHandelr(popupOverlay); addPopupCloserHandelr(popupOverlay);
} }
@ -226,14 +266,17 @@ public abstract class OpenLayerOSM {
popContent.setInnerHTML(html); popContent.setInnerHTML(html);
popupOverlay.setPosition(coordinate); popupOverlay.setPosition(coordinate);
} }
/**
* Hide popup.
*/
public void hidePopup() { public void hidePopup() {
if(popupOverlay!=null) { if (popupOverlay != null) {
Element elPopup = DOM.getElementById("popup"); Element elPopup = DOM.getElementById("popup");
elPopup.getStyle().setVisibility(Visibility.HIDDEN); elPopup.getStyle().setVisibility(Visibility.HIDDEN);
} }
} }
/** /**
* Adds the popup closer handelr. * Adds the popup closer handelr.
* *
@ -253,11 +296,11 @@ public abstract class OpenLayerOSM {
} }
}); });
} }
/** /**
* Handler popu closer. * Handler popu closer.
* *
* @param divId the div id * @param divId the div id
* @param overlayId the overlay id * @param overlayId the overlay id
*/ */
public static native void handlerPopuCloser(String divId, String overlayId) /*-{ public static native void handlerPopuCloser(String divId, String overlayId) /*-{
@ -271,21 +314,20 @@ public abstract class OpenLayerOSM {
}-*/; }-*/;
/** /**
* Adds the WMS layer. * Adds the WMS layer.
* *
* @param layerItem the layer item * @param layerItem the layer item
*/ */
public void addWMSLayer(LayerItem layerItem) { public void addWMSLayer(LayerItem layerItem) {
ImageWmsParams imageWMSParams = OLFactory.createOptions(); ImageWmsParams imageWMSParams = OLFactory.createOptions();
imageWMSParams.setLayers(layerItem.getName()); imageWMSParams.setLayers(layerItem.getName());
ImageWmsOptions imageWMSOptions = OLFactory.createOptions(); ImageWmsOptions imageWMSOptions = OLFactory.createOptions();
imageWMSOptions.setUrl(layerItem.getMapServerHost()); imageWMSOptions.setUrl(layerItem.getMapServerHost());
imageWMSOptions.setParams(imageWMSParams); imageWMSOptions.setParams(imageWMSParams);
//imageWMSOptions.setRatio(1.5f); // imageWMSOptions.setRatio(1.5f);
ImageWms imageWMSSource = new ImageWms(imageWMSOptions); ImageWms imageWMSSource = new ImageWms(imageWMSOptions);
@ -293,29 +335,142 @@ public abstract class OpenLayerOSM {
layerOptions.setSource(imageWMSSource); layerOptions.setSource(imageWMSSource);
Image wmsLayer = new Image(layerOptions); Image wmsLayer = new Image(layerOptions);
//visibleLayerItems // visibleLayerItems
map.addLayer(wmsLayer); map.addLayer(wmsLayer);
GWT.log("Fired the event Added Layer"); GWT.log("Fired the event Added Layer");
eventBus.fireEvent(new AddedLayerToMapEvent(layerItem)); eventBus.fireEvent(new AddedLayerToMapEvent(layerItem));
} }
/**
* Adds the WMS detail layer.
*
* @param layerItem the layer item
*/
public void addWMSDetailLayer(LayerItem layerItem) {
if (wmsDetailsLayerMap == null)
wmsDetailsLayerMap = new HashMap<String, Image>();
String key = layerItem.getMapServerHost() + "/layer/" + layerItem.getName();
Image layer = wmsDetailsLayerMap.get(key);
if (layer == null) {
GWT.log("The detail layer with key: " + key + " does not exist, creating and adding it to map");
ImageWmsParams imageWMSParams = OLFactory.createOptions();
imageWMSParams.setLayers(layerItem.getName());
ImageWmsOptions imageWMSOptions = OLFactory.createOptions();
imageWMSOptions.setUrl(layerItem.getMapServerHost());
imageWMSOptions.setParams(imageWMSParams);
// imageWMSOptions.setRatio(1.5f);
ImageWms imageWMSSource = new ImageWms(imageWMSOptions);
LayerOptions layerOptions = OLFactory.createOptions();
layerOptions.setSource(imageWMSSource);
Image wmsLayer = new Image(layerOptions);
// visibleLayerItems
map.addLayer(wmsLayer);
wmsDetailsLayerMap.put(key, wmsLayer);
GWT.log("Fired the event Added Layer");
eventBus.fireEvent(new AddedLayerToMapEvent(layerItem));
} else {
GWT.log("The detail layer with key: " + key + " already exists, skipping");
}
}
public void removeAllDetailLayers() {
if (wmsDetailsLayerMap == null)
return;
for (String key : wmsDetailsLayerMap.keySet()) {
Image layer = wmsDetailsLayerMap.get(key);
map.removeLayer(layer);
}
wmsDetailsLayerMap.clear();
}
// public void addGeometry(Geometry theGeom) {
//
// if(theGeom==null)
// return;
//
// if(geometryLayer==null) {
// geometryLayer = new Vector("Feature selected");
// geometryLayer.setDisplayInLayerSwitcher(false);
// map.addLayer(geometryLayer);
// }else {
// geometryLayer.removeAllFeatures();
// }
// Style style = new Style();
// style.setFillColor("#00FF00");
// style.setGraphicName("circle");
// style.setPointRadius(10);
// VectorFeature vf = new VectorFeature(theGeom, style);
// geometryLayer.addFeature(vf);
// }
//
//
// protected void removeGeometries() {
// if(geometryLayer!=null)
// geometryLayer.removeAllFeatures();
// }
/**
* Adds the vector.
*
* @param geometry the geometry
*/
public void addVector(Geometry geometry) {
VectorLayerOptions vectorLayerOptions = new VectorLayerOptions();
vectorLayerOptions.setMap(map);
// Style style = new Style();
// FillOptions fillOptions = new FillOptions();
// Color color = new Color(0, 0, 255, 1.0);
// fillOptions.setColor(color);
// Fill fill = new Fill(fillOptions);
// style.setFill(fill);
FeatureOptions featureOptions = new FeatureOptions();
featureOptions.setGeometry(geometry);
Feature feature = OLFactory.createFeature(featureOptions);
Vector vectorSource = OLFactory.createVectorSource();
vectorSource.addFeature(feature);
vectorLayerOptions.setSource(vectorSource);
ol.layer.Vector vector = OLFactory.createVector(vectorLayerOptions);
map.addLayer(vector);
}
/** /**
* Adds the point vector source. * Adds the point vector source.
* *
* @return the draw * @return the draw
*/ */
public Draw addPointVectorSource() { public Draw addPointVectorSource() {
if(queryPoint==null) if (queryPoint == null)
initPointInteraction(); initPointInteraction();
map.addInteraction(queryPoint); map.addInteraction(queryPoint);
isQueryPointActive = true; isQueryPointActive = true;
return queryPoint; return queryPoint;
} }
/** /**
* Inits the point interaction. * Inits the point interaction.
*/ */
@ -328,39 +483,39 @@ public abstract class OpenLayerOSM {
drawOptions.setMinPoints(1); drawOptions.setMinPoints(1);
drawOptions.setWrapX(false); drawOptions.setWrapX(false);
queryPoint = new Draw(drawOptions); queryPoint = new Draw(drawOptions);
queryPoint.addChangeListener(new EventListener<ol.events.Event>() { queryPoint.addChangeListener(new EventListener<ol.events.Event>() {
@Override @Override
public void onEvent(ol.events.Event event) { public void onEvent(ol.events.Event event) {
GWT.log(event.getType()); GWT.log(event.getType());
} }
}); });
} }
/** /**
* Removes the interaction. * Removes the interaction.
* *
* @param interaction the interaction * @param interaction the interaction
*/ */
public void removeInteraction(Interaction interaction) { public void removeInteraction(Interaction interaction) {
map.removeInteraction(interaction); map.removeInteraction(interaction);
} }
/** /**
* Removes the interactions. * Removes the interactions.
*/ */
public void removeQueryInteractions() { public void removeQueryInteractions() {
Collection<Interaction> interactions = map.getInteractions(); Collection<Interaction> interactions = map.getInteractions();
if(interactions!=null) { if (interactions != null) {
map.removeInteraction(queryBox); map.removeInteraction(queryBox);
map.removeInteraction(queryPoint); map.removeInteraction(queryPoint);
isQueryBoxActive = false; isQueryBoxActive = false;
isQueryPointActive = false; isQueryPointActive = false;
} }
} }
/** /**
* Adds the extent interaction. * Adds the extent interaction.
* *
@ -369,17 +524,16 @@ public abstract class OpenLayerOSM {
public Extent addExtentInteraction() { public Extent addExtentInteraction() {
ExtentOptions extentOptions = new ExtentOptions(); ExtentOptions extentOptions = new ExtentOptions();
extentOptions.setWrapX(false); extentOptions.setWrapX(false);
//StyleOptions styleOptions = new StyleOptions(); // StyleOptions styleOptions = new StyleOptions();
//styleOptions.setStroke(stroke); // styleOptions.setStroke(stroke);
//styleOptions.set // styleOptions.set
//extentOptions.setBoxStyle(new ol.style.Style(styleOptions)); // extentOptions.setBoxStyle(new ol.style.Style(styleOptions));
queryBox = new Extent(extentOptions); queryBox = new Extent(extentOptions);
map.addInteraction(queryBox); map.addInteraction(queryBox);
isQueryBoxActive = true; isQueryBoxActive = true;
return queryBox; return queryBox;
} }
/** /**
* Adds the overlay. * Adds the overlay.
* *
@ -405,23 +559,22 @@ public abstract class OpenLayerOSM {
* @return true, if is layer visible * @return true, if is layer visible
*/ */
public boolean isLayerVisible(String layerName) { public boolean isLayerVisible(String layerName) {
Collection<Base> layers = map.getLayers(); Collection<Base> layers = map.getLayers();
if(layers!=null) { if (layers != null) {
Base[] layersArr = layers.getArray(); Base[] layersArr = layers.getArray();
for (int i = 0; i < layersArr.length; i++) { for (int i = 0; i < layersArr.length; i++) {
Base layer = layersArr[i]; Base layer = layersArr[i];
String theLayerName = (String) layer.get("name"); String theLayerName = (String) layer.get("name");
GWT.log("The Layer name is: "+layerName); GWT.log("The Layer name is: " + layerName);
if(theLayerName!=null && theLayerName.equals(layerName)) if (theLayerName != null && theLayerName.equals(layerName))
return true; return true;
} }
} }
return false; return false;
} }
/** /**
* Gets the projection code. * Gets the projection code.
@ -431,7 +584,6 @@ public abstract class OpenLayerOSM {
public String getProjectionCode() { public String getProjectionCode() {
return map.getView().getProjection().getCode(); return map.getView().getProjection().getCode();
} }
/** /**
* Gets the current zoom level. * Gets the current zoom level.
@ -441,9 +593,7 @@ public abstract class OpenLayerOSM {
public double getCurrentZoomLevel() { public double getCurrentZoomLevel() {
return map.getView().getZoom(); return map.getView().getZoom();
} }
/** /**
* Gets the bbox. * Gets the bbox.
* *
@ -452,7 +602,7 @@ public abstract class OpenLayerOSM {
public ol.Extent getBBOX() { public ol.Extent getBBOX() {
return getExtent(); return getExtent();
} }
/** /**
* Gets the extent. * Gets the extent.
* *
@ -461,26 +611,53 @@ public abstract class OpenLayerOSM {
public ol.Extent getExtent() { public ol.Extent getExtent() {
return this.map.getView().calculateExtent(map.getSize()); return this.map.getView().calculateExtent(map.getSize());
} }
public Coordinate transform (Coordinate centerCoordinate, String source, String target){ /**
return Projection.transform(centerCoordinate, source, target); * Transform.
*
* @param centerCoordinate the center coordinate
* @param source the source
* @param target the target
* @return the coordinate
*/
public Coordinate transform(Coordinate centerCoordinate, String source, String target) {
return Projection.transform(centerCoordinate, source, target);
} }
/**
* Checks if is query box active.
*
* @return true, if is query box active
*/
public boolean isQueryBoxActive() { public boolean isQueryBoxActive() {
return isQueryBoxActive; return isQueryBoxActive;
} }
/**
* Checks if is query point active.
*
* @return true, if is query point active
*/
public boolean isQueryPointActive() { public boolean isQueryPointActive() {
return isQueryPointActive; return isQueryPointActive;
} }
/**
* Gets the size.
*
* @return the size
*/
public Size getSize() { public Size getSize() {
return map.getSize(); return map.getSize();
} }
/**
* Map instancied.
*
* @return true, if successful
*/
public boolean mapInstancied() { public boolean mapInstancied() {
return this.map!=null; return this.map != null;
} }
} }

View File

@ -140,22 +140,24 @@ public class ImagesGallery {
JSONArray jsonArray = new JSONArray(); JSONArray jsonArray = new JSONArray();
int index = 0; int index = 0;
for (UploadedImageDV image : listImages) { for (UploadedImageDV image : listImages) {
for (WorkspaceContentDV imageContent : image.getListWsContent()) { if(image.getListWsContent()!=null) {
JSONObject json = new JSONObject(); for (WorkspaceContentDV imageContent : image.getListWsContent()) {
json.put("src", new JSONString(imageContent.getLink())); JSONObject json = new JSONObject();
json.put("srct", new JSONString(imageContent.getLink())); json.put("src", new JSONString(imageContent.getLink()));
List<String> listAuthors = image.getResponsabili(); json.put("srct", new JSONString(imageContent.getLink()));
String txtAuthors = listAuthors.size()>1 ? "Authors: ": "Author: "; List<String> listAuthors = image.getResponsabili();
for (String author : listAuthors) { String txtAuthors = listAuthors.size()>1 ? "Authors: ": "Author: ";
txtAuthors+= " "+author +","; for (String author : listAuthors) {
txtAuthors+= " "+author +",";
}
txtAuthors = txtAuthors.substring(0,txtAuthors.length()-2);
String description = txtAuthors + ". ID Licenza: "+image.getLicenseID();
json.put("title", new JSONString(image.getDidascalia()));
json.put("description", new JSONString(description));
json.put("downloadURL", new JSONString(imageContent.getLink()));
jsonArray.set(index, json);
index++;
} }
txtAuthors = txtAuthors.substring(0,txtAuthors.length()-2);
String description = txtAuthors + ". ID Licenza: "+image.getLicenseID();
json.put("title", new JSONString(image.getDidascalia()));
json.put("description", new JSONString(description));
json.put("downloadURL", new JSONString(imageContent.getLink()));
jsonArray.set(index, json);
index++;
} }
} }

View File

@ -230,8 +230,8 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
/** /**
* Gets the layers for id. * Gets the layers for id.
* *
* @param itemType the item type * @param itemType the item type
* @param itemId the item id * @param itemId the item id
* @return the layers for id * @return the layers for id
* @throws Exception the exception * @throws Exception the exception
*/ */
@ -469,4 +469,36 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
return SessionUtil.isSessionExpired(this.getThreadLocalRequest()); return SessionUtil.isSessionExpired(this.getThreadLocalRequest());
} }
/**
* Gets the WFS features.
*
* @param layerObjects the layer objects
* @param mapSrsName the map srs name
* @param selectBBOX the select BBOX
* @param maxWFSFeature the max WFS feature
* @param zoomLevel the zoom level
* @return the WFS features
*/
@Override
public List<GeoNaSpatialQueryResult> getWFSFeatures(List<LayerObject> layerObjects, String mapSrsName,
BoundsMap selectBBOX, int maxWFSFeature, double zoomLevel) {
LOG.info("getWFSFeatures called");
List<GeoNaSpatialQueryResult> listDAO = new ArrayList<GeoNaSpatialQueryResult>(layerObjects.size());
for (LayerObject layerObject : layerObjects) {
GeoNaSpatialQueryResult geoDAO = new GeoNaSpatialQueryResult();
List<FeatureRow> features = FeatureParser.getWFSFeatures(layerObject.getLayerItem(), mapSrsName, selectBBOX,
maxWFSFeature);
LOG.debug("For layer name: " + layerObject.getLayerItem().getName() + " got features: " + features);
geoDAO.setFeatures(features);
geoDAO.setSourceLayerObject(layerObject);
LOG.info("For layer name: " + layerObject.getLayerItem().getName() + " got " + features.size()
+ " feature/s");
listDAO.add(geoDAO);
}
LOG.info("returning " + listDAO + " geona data objects");
return listDAO;
}
} }