2020-11-12 18:25:24 +01:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
*/
|
2020-10-27 16:04:34 +01:00
|
|
|
package org.gcube.portlets.user.geoportaldataviewer.client;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
2020-10-30 12:19:51 +01:00
|
|
|
import java.util.Map;
|
2020-10-27 16:04:34 +01:00
|
|
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.LayerType;
|
2020-10-29 15:18:14 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEvent;
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEventHandler;
|
2020-11-03 13:09:08 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEvent;
|
2020-10-27 16:04:34 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM;
|
2020-11-16 12:09:11 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil;
|
2020-10-27 16:04:34 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil;
|
2020-10-29 15:18:14 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataObject;
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap;
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery;
|
2020-10-27 16:04:34 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
|
2020-11-13 16:37:34 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
|
2020-11-03 13:09:08 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow;
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest;
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.ZAxis;
|
2020-11-16 12:09:11 +01:00
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.WorkspaceContentDV;
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.products.model.UploadedImageDV;
|
2020-10-27 16:04:34 +01:00
|
|
|
|
2020-11-03 13:09:08 +01:00
|
|
|
import com.github.gwtbootstrap.client.ui.Button;
|
|
|
|
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
|
2020-10-27 16:04:34 +01:00
|
|
|
import com.google.gwt.core.client.GWT;
|
2020-11-03 18:04:47 +01:00
|
|
|
import com.google.gwt.core.client.Scheduler;
|
|
|
|
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
2020-11-03 13:09:08 +01:00
|
|
|
import com.google.gwt.event.dom.client.ClickEvent;
|
|
|
|
import com.google.gwt.event.dom.client.ClickHandler;
|
2020-10-29 15:18:14 +01:00
|
|
|
import com.google.gwt.event.shared.HandlerManager;
|
2020-11-03 18:04:47 +01:00
|
|
|
import com.google.gwt.user.client.DOM;
|
|
|
|
import com.google.gwt.user.client.Element;
|
|
|
|
import com.google.gwt.user.client.Event;
|
|
|
|
import com.google.gwt.user.client.EventListener;
|
2020-10-27 16:04:34 +01:00
|
|
|
import com.google.gwt.user.client.Window;
|
|
|
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
2020-10-30 12:19:51 +01:00
|
|
|
import com.google.gwt.user.client.ui.FlexTable;
|
|
|
|
import com.google.gwt.user.client.ui.HTML;
|
2020-11-03 18:04:47 +01:00
|
|
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
2020-10-27 16:04:34 +01:00
|
|
|
|
2020-10-29 17:08:29 +01:00
|
|
|
import ol.Coordinate;
|
|
|
|
|
2020-10-29 15:18:14 +01:00
|
|
|
|
2020-10-27 16:04:34 +01:00
|
|
|
/**
|
|
|
|
* The Class LayerManager.
|
|
|
|
*
|
|
|
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
|
|
|
*
|
|
|
|
* Oct 27, 2020
|
|
|
|
*/
|
|
|
|
public class LayerManager {
|
|
|
|
|
|
|
|
/** The ol map. */
|
|
|
|
private OpenLayerOSM olMap;
|
2020-11-13 16:37:34 +01:00
|
|
|
|
|
|
|
private List<LayerObject> layerObjects = new ArrayList<LayerObject>();
|
2020-10-29 15:18:14 +01:00
|
|
|
|
|
|
|
private HandlerManager eventBus = new HandlerManager("");
|
2020-10-27 16:04:34 +01:00
|
|
|
|
2020-11-03 13:09:08 +01:00
|
|
|
private HandlerManager applicationBus;
|
|
|
|
|
2020-10-27 16:04:34 +01:00
|
|
|
/**
|
|
|
|
* Instantiates a new layer manager.
|
2020-11-12 18:25:24 +01:00
|
|
|
*
|
|
|
|
* @param applicationBus the application bus
|
2020-10-27 16:04:34 +01:00
|
|
|
*/
|
2020-11-03 13:09:08 +01:00
|
|
|
public LayerManager(HandlerManager applicationBus) {
|
|
|
|
this.applicationBus = applicationBus;
|
2020-10-29 15:18:14 +01:00
|
|
|
bindEvents();
|
2020-10-27 16:04:34 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-11-12 18:25:24 +01:00
|
|
|
/**
|
|
|
|
* Bind events.
|
|
|
|
*/
|
2020-10-29 15:18:14 +01:00
|
|
|
private void bindEvents() {
|
|
|
|
|
|
|
|
eventBus.addHandler(QueryDataEvent.TYPE, new QueryDataEventHandler() {
|
|
|
|
|
|
|
|
@Override
|
2020-10-30 12:19:51 +01:00
|
|
|
public void onQueryInteraction(final QueryDataEvent queryEvent) {
|
2020-10-29 15:18:14 +01:00
|
|
|
|
|
|
|
if(queryEvent.getGeoQuery()!=null) {
|
|
|
|
GeoQuery selectDataInfo = queryEvent.getGeoQuery();
|
|
|
|
GWT.log("("+selectDataInfo.getX1()+","+selectDataInfo.getY1()+")("+selectDataInfo.getX2()+","+selectDataInfo.getY2()+")");
|
|
|
|
|
2020-11-13 16:37:34 +01:00
|
|
|
for (LayerObject layerObj : layerObjects){
|
2020-10-29 15:18:14 +01:00
|
|
|
//TODO
|
2020-11-13 16:37:34 +01:00
|
|
|
isLayerVisible(layerObj.getLayerItem());
|
2020-10-29 15:18:14 +01:00
|
|
|
|
|
|
|
}
|
2020-10-29 17:08:29 +01:00
|
|
|
|
2020-10-29 15:18:14 +01:00
|
|
|
BoundsMap mapBBOX = new BoundsMap();
|
2020-10-29 17:08:29 +01:00
|
|
|
//THIS IS SHOULD BE CORRET, THE BOUND AND CRS ARE READ FROM MAP
|
|
|
|
/*mapBBOX.setCrs(olMap.getProjectionCode());
|
2020-10-29 15:18:14 +01:00
|
|
|
mapBBOX.setLowerLeftX(olMap.getExtent().getLowerLeftX());
|
|
|
|
mapBBOX.setLowerLeftY(olMap.getExtent().getLowerLeftY());
|
|
|
|
mapBBOX.setUpperRightX(olMap.getExtent().getUpperRightX());
|
|
|
|
mapBBOX.setUpperRightY(olMap.getExtent().getUpperRightY());
|
2020-10-29 17:08:29 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
//THE FOLLOWING SHOULD BE NOT NEEDED BUT THE GETFEATURE WITH EPSG_3857 SEEMS NOT WORK IN OUR GEOSERVER
|
2020-10-29 17:48:20 +01:00
|
|
|
// double minX = olMap.getExtent().getLowerLeftX();
|
|
|
|
// double minY = olMap.getExtent().getLowerLeftY();
|
|
|
|
double minX = queryEvent.getGeoQuery().getX1();
|
|
|
|
double minY = queryEvent.getGeoQuery().getY1();
|
2020-10-29 17:08:29 +01:00
|
|
|
Coordinate centerCoordinate = new Coordinate(minX, minY);
|
|
|
|
centerCoordinate = olMap.transform(centerCoordinate, GeoportalDataViewerConstants.EPSG_3857, GeoportalDataViewerConstants.EPSG_4326);
|
|
|
|
mapBBOX.setLowerLeftX(centerCoordinate.getX());
|
|
|
|
mapBBOX.setLowerLeftY(centerCoordinate.getY());
|
|
|
|
|
2020-10-29 17:48:20 +01:00
|
|
|
// double maxX = olMap.getExtent().getUpperRightX();
|
|
|
|
// double maxY = olMap.getExtent().getUpperRightY();
|
|
|
|
double maxX = queryEvent.getGeoQuery().getX2();
|
|
|
|
double maxY = queryEvent.getGeoQuery().getY2();
|
2020-10-29 17:08:29 +01:00
|
|
|
centerCoordinate = new Coordinate(maxX,maxY);
|
|
|
|
centerCoordinate = olMap.transform(centerCoordinate, GeoportalDataViewerConstants.EPSG_3857, GeoportalDataViewerConstants.EPSG_4326);
|
|
|
|
mapBBOX.setUpperRightX(centerCoordinate.getX());
|
|
|
|
mapBBOX.setUpperRightY(centerCoordinate.getY());
|
|
|
|
|
|
|
|
mapBBOX.setCrs(GeoportalDataViewerConstants.EPSG_4326);
|
|
|
|
|
|
|
|
GWT.log("Bounds is: "+mapBBOX);
|
2020-10-29 15:18:14 +01:00
|
|
|
|
2020-11-13 16:37:34 +01:00
|
|
|
GeoportalDataViewerServiceAsync.Util.getInstance().getDataResult(layerObjects, olMap.getProjectionCode(), mapBBOX, GeoportalDataViewerConstants.MAX_WFS_FEATURES, olMap.getCurrentZoomLevel(), new AsyncCallback<List<GeoNaDataObject>>() {
|
2020-10-29 15:18:14 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-11-13 16:37:34 +01:00
|
|
|
public void onSuccess(List<GeoNaDataObject> listGeonaDataObjects) {
|
2020-10-30 12:19:51 +01:00
|
|
|
|
2020-11-13 16:37:34 +01:00
|
|
|
GWT.log("GeoNaDataObject's: "+listGeonaDataObjects);
|
2020-10-30 12:19:51 +01:00
|
|
|
|
2020-11-13 16:37:34 +01:00
|
|
|
if(listGeonaDataObjects==null || listGeonaDataObjects.isEmpty())
|
|
|
|
return;
|
|
|
|
|
2020-10-30 12:19:51 +01:00
|
|
|
FlexTable flex = new FlexTable();
|
|
|
|
flex.setCellPadding(1);
|
|
|
|
flex.setCellSpacing(1);
|
|
|
|
flex.getElement().addClassName("popup-table");
|
2020-11-02 18:18:03 +01:00
|
|
|
boolean featureFound = false;
|
2020-11-03 18:04:47 +01:00
|
|
|
FeatureRow feature = null;
|
2020-11-13 17:14:08 +01:00
|
|
|
|
|
|
|
//TODO SWTCH FOR EARCH ITEM TYPE
|
2020-11-13 16:37:34 +01:00
|
|
|
for (GeoNaDataObject geoNaDataObject : listGeonaDataObjects) {
|
2020-11-02 18:18:03 +01:00
|
|
|
List<FeatureRow> features = geoNaDataObject.getFeatures();
|
2020-11-13 16:37:34 +01:00
|
|
|
|
|
|
|
//USING ONLY THE FIRST FEATURE IN THE LIST
|
2020-11-02 18:18:03 +01:00
|
|
|
if(features!=null && features.size()>0) {
|
2020-11-03 18:04:47 +01:00
|
|
|
feature = features.get(0);
|
2020-11-16 12:09:11 +01:00
|
|
|
Map<String, List<String>> entries = feature.getMapProperties();
|
2020-11-02 18:18:03 +01:00
|
|
|
|
|
|
|
for (String key : entries.keySet()) {
|
2020-11-16 12:09:11 +01:00
|
|
|
String theValue = entries.get(key).get(0);
|
2020-11-02 18:18:03 +01:00
|
|
|
if(key.equalsIgnoreCase("nome")) {
|
2020-11-16 12:09:11 +01:00
|
|
|
flex.setHTML(0, 0, new HTML(theValue).toString());
|
2020-11-02 18:18:03 +01:00
|
|
|
}
|
|
|
|
else if(key.equalsIgnoreCase("descrizione")) {
|
2020-11-16 12:09:11 +01:00
|
|
|
String reducedValue = theValue;
|
|
|
|
try {
|
|
|
|
reducedValue = StringUtil.ellipsize(theValue, 300);
|
|
|
|
GWT.log("reduced: "+reducedValue);
|
|
|
|
} catch (Exception e) {
|
|
|
|
GWT.log("error: "+e.getMessage());
|
|
|
|
}
|
|
|
|
flex.setText(1, 0, reducedValue);
|
2020-11-02 18:18:03 +01:00
|
|
|
}else if(key.equalsIgnoreCase("date_scavo")) {
|
2020-11-16 12:09:11 +01:00
|
|
|
flex.setHTML(2, 0, new HTML("<code>"+theValue).toString()+"</code>");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void execute() {
|
|
|
|
List<String> listConcessioni = entries.get("product_id");
|
|
|
|
if(listConcessioni!=null && listConcessioni.size()>0) {
|
|
|
|
String concessioneId = listConcessioni.get(0);
|
|
|
|
try {
|
|
|
|
Long theConcessioneId = Long.parseLong(concessioneId);
|
|
|
|
GeoportalDataViewerServiceAsync.Util.getInstance().getUploadedImagesForId("Concessione", theConcessioneId, 1, new AsyncCallback<List<UploadedImageDV>>() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
// TODO Auto-generated method stub
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onSuccess(List<UploadedImageDV> result) {
|
|
|
|
GWT.log("Loaded images: "+result);
|
|
|
|
|
|
|
|
for (UploadedImageDV img : result) {
|
|
|
|
if(img.getListWsContent()!=null) {
|
|
|
|
WorkspaceContentDV wsContent = img.getListWsContent().get(img.getListWsContent().size()-1);
|
|
|
|
String theImgHTML = "<img src=\""+wsContent.getLink()+"\"></img>";
|
|
|
|
GWT.log("theImgHTML: "+theImgHTML);
|
|
|
|
flex.setHTML(flex.getRowCount()+1, 0, theImgHTML);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}catch (Exception e) {
|
|
|
|
// TODO: handle exception
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
});*/
|
|
|
|
|
|
|
|
|
|
|
|
if(geoNaDataObject.getMapImages()!=null) {
|
|
|
|
for (Long key : geoNaDataObject.getMapImages().keySet()) {
|
|
|
|
List<UploadedImageDV> listUI = geoNaDataObject.getMapImages().get(key);
|
|
|
|
GWT.log("Adding images: "+listUI);
|
|
|
|
if(listUI!=null) {
|
|
|
|
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);
|
|
|
|
flex.setHTML(flex.getRowCount()+1, 0, theImgHTML);
|
|
|
|
}
|
|
|
|
}
|
2020-11-02 18:18:03 +01:00
|
|
|
}
|
2020-10-30 12:19:51 +01:00
|
|
|
}
|
2020-11-03 18:04:47 +01:00
|
|
|
|
2020-11-02 18:18:03 +01:00
|
|
|
featureFound = true;
|
2020-11-13 16:37:34 +01:00
|
|
|
//break; //Only the first one
|
|
|
|
}
|
|
|
|
|
|
|
|
GWT.log("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);
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
2020-10-30 12:19:51 +01:00
|
|
|
}
|
2020-11-11 12:05:21 +01:00
|
|
|
|
2020-11-13 16:37:34 +01:00
|
|
|
olMap.showPopup(vpPanel.toString(), queryEvent.getoLCoordinate());
|
|
|
|
|
|
|
|
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
|
|
|
|
2020-11-11 12:05:21 +01:00
|
|
|
@Override
|
2020-11-13 16:37:34 +01:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2020-11-11 12:05:21 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2020-10-29 15:18:14 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2020-11-13 16:37:34 +01:00
|
|
|
|
|
|
|
|
|
|
|
private ShowDetailsEvent parseGeonaReferences(String itemType, FeatureRow fRow) {
|
|
|
|
if(fRow==null)
|
|
|
|
return null;
|
|
|
|
|
|
|
|
List<String> productIds = fRow.getMapProperties().get("product_id");
|
|
|
|
if(productIds!=null && productIds.size()>0) {
|
|
|
|
long id = Long.parseLong(productIds.get(0));
|
|
|
|
String itemName = "Dettagli Prodotto";
|
|
|
|
List<String> listName = fRow.getMapProperties().get("nome");
|
|
|
|
if(listName!=null && listName.size()>0) {
|
|
|
|
itemName = listName.get(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return new ShowDetailsEvent(itemType, id, itemName, fRow);
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
2020-10-29 15:18:14 +01:00
|
|
|
|
|
|
|
|
2020-10-27 16:04:34 +01:00
|
|
|
/**
|
2020-11-13 16:37:34 +01:00
|
|
|
* Adds the layer.
|
2020-10-27 16:04:34 +01:00
|
|
|
*
|
2020-11-13 16:37:34 +01:00
|
|
|
* @param geonaItemType the geona item type
|
2020-10-27 16:04:34 +01:00
|
|
|
* @param layerTitle the layer title
|
|
|
|
* @param layerName the layer name
|
2020-11-13 16:37:34 +01:00
|
|
|
* @param wmsLink the wms link
|
2020-10-27 16:04:34 +01:00
|
|
|
* @param isBase the is base
|
|
|
|
* @param displayInLayerSwitcher the display in layer switcher
|
|
|
|
* @param UUID the uuid
|
|
|
|
* @param onTop the on top
|
|
|
|
*/
|
2020-11-13 16:37:34 +01:00
|
|
|
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 boolean onTop) {
|
2020-10-27 16:04:34 +01:00
|
|
|
|
|
|
|
// final LayoutContainer westPanel = (LayoutContainer) layersPanel.getParent();
|
|
|
|
//
|
|
|
|
// if(layersPanel.getLayerItems().size()==0)
|
|
|
|
// westPanel.mask("Adding..."+layerName, "x-mask-loading");
|
|
|
|
// else
|
|
|
|
// layersPanel.mask("Adding..."+layerName, "x-mask-loading");
|
|
|
|
|
|
|
|
final LayerType featureType = isBase?LayerType.RASTER_BASELAYER:LayerType.FEATURE_TYPE;
|
|
|
|
// Info.display("Adding Layer", layerName);
|
2020-11-13 16:37:34 +01:00
|
|
|
GeoportalDataViewerServiceAsync.Util.getInstance().parseWmsRequest(wmsLink, layerName, new AsyncCallback<GeoInformationForWMSRequest>() {
|
2020-10-27 16:04:34 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onFailure(Throwable caught) {
|
|
|
|
|
|
|
|
Window.alert(caught.getMessage());
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2020-11-13 16:37:34 +01:00
|
|
|
public void onSuccess(GeoInformationForWMSRequest geoInfoWMS) {
|
2020-10-27 16:04:34 +01:00
|
|
|
|
2020-11-13 16:37:34 +01:00
|
|
|
GWT.log("Parsed WMS Request returned: "+geoInfoWMS);
|
|
|
|
//ddLayerByWms(featureType, layerTitle, result.getLayerName(), result.getWmsRequest(), result.getBaseWmsServiceHost(), true, isBase, displayInLayerSwitcher, (ArrayList<String>) result.getStyles().getGeoStyles(), result.getWmsRequest(), false, result.getMapWMSNoStandard(), result.isNcWMS(), UUID, result.getZAxis());
|
2020-10-27 16:04:34 +01:00
|
|
|
|
2020-11-13 16:37:34 +01:00
|
|
|
LayerItem layerItem = toLayerItem(featureType, layerTitle, geoInfoWMS.getLayerName(), geoInfoWMS.getWmsRequest(), geoInfoWMS.getBaseWmsServiceHost(), true, isBase, displayInLayerSwitcher, (ArrayList<String>) geoInfoWMS.getStyles().getGeoStyles(), geoInfoWMS.getWmsRequest(), false, geoInfoWMS.getMapWMSNoStandard(), geoInfoWMS.isNcWMS(), UUID, geoInfoWMS.getZAxis());
|
|
|
|
LayerObject lo = new LayerObject();
|
|
|
|
lo.setLayerItem(layerItem);
|
|
|
|
lo.setItemType(geonaItemType);
|
|
|
|
layerObjects.add(lo);
|
|
|
|
olMap.addWMSLayer(layerItem.getMapServerHost(), layerItem.getName());
|
2020-10-27 16:04:34 +01:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-11-12 18:25:24 +01:00
|
|
|
|
2020-10-27 16:04:34 +01:00
|
|
|
/**
|
2020-11-13 16:37:34 +01:00
|
|
|
* To layer item.
|
2020-10-27 16:04:34 +01:00
|
|
|
*
|
|
|
|
* @param layerType the layer type
|
|
|
|
* @param layerTitle the layer title
|
|
|
|
* @param layerName the layer name
|
|
|
|
* @param layerURL the layer URL
|
|
|
|
* @param mapServerHost the map server host
|
|
|
|
* @param isExternal the is external
|
|
|
|
* @param isBase the is base
|
|
|
|
* @param displayInLayerSwitcher the display in layer switcher
|
|
|
|
* @param styles the styles
|
2020-11-12 18:25:24 +01:00
|
|
|
* @param wmsLink the wms link
|
2020-10-27 16:04:34 +01:00
|
|
|
* @param onTop the on top
|
|
|
|
* @param wmsNotStandardParams the wms not standard params
|
|
|
|
* @param isNcWms the is nc wms
|
|
|
|
* @param UUID the uuid
|
|
|
|
* @param zAxis the z axis
|
2020-11-13 16:37:34 +01:00
|
|
|
* @return the layer item
|
2020-10-27 16:04:34 +01:00
|
|
|
*/
|
2020-11-13 16:37:34 +01:00
|
|
|
private LayerItem toLayerItem(LayerType layerType, String layerTitle, String layerName, String layerURL, String mapServerHost, boolean isExternal, boolean isBase, boolean displayInLayerSwitcher, ArrayList<String> styles, String wmsLink, boolean onTop, HashMap<String, String> wmsNotStandardParams, boolean isNcWms, String UUID, ZAxis zAxis) {
|
2020-10-27 16:04:34 +01:00
|
|
|
|
|
|
|
// GWT.log("Add addLayerByWms 1");
|
2020-10-29 15:18:14 +01:00
|
|
|
LayerItem layerItem = new LayerItem();
|
|
|
|
layerItem.setBaseLayer(isBase);
|
|
|
|
layerItem.setTitle(layerTitle);
|
|
|
|
layerItem.setName(layerName);
|
|
|
|
layerItem.setUrl(layerURL);
|
|
|
|
layerItem.setMapServerHost(mapServerHost);
|
2020-10-27 16:04:34 +01:00
|
|
|
//l.setExternal(isExternal);
|
2020-10-29 15:18:14 +01:00
|
|
|
layerItem.setOpacity(1d);
|
|
|
|
layerItem.setBuffer(2);
|
2020-11-12 18:25:24 +01:00
|
|
|
layerItem.setWmsLink(wmsLink);
|
2020-10-29 15:18:14 +01:00
|
|
|
layerItem.setWmsNotStandardParams(wmsNotStandardParams);
|
|
|
|
layerItem.setNcWms(isNcWms);
|
|
|
|
layerItem.setUUID(UUID);
|
|
|
|
layerItem.setZAxis(zAxis);
|
2020-10-27 16:04:34 +01:00
|
|
|
|
|
|
|
switch (layerType) {
|
|
|
|
|
|
|
|
//TODO IMPLEMENT THIS CASE
|
|
|
|
case RASTER_BASELAYER:
|
|
|
|
|
|
|
|
// l.setHasLegend(false);
|
2020-10-29 15:18:14 +01:00
|
|
|
layerItem.setBaseLayer(true);
|
|
|
|
layerItem.setTrasparent(false);
|
|
|
|
layerItem.setClickData(false);
|
2020-10-27 16:04:34 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case FEATURE_TYPE:
|
|
|
|
|
|
|
|
//CASE FEATURE TYPE
|
2020-10-29 15:18:14 +01:00
|
|
|
layerItem.setBaseLayer(false);
|
|
|
|
layerItem.setClickData(true);
|
|
|
|
layerItem.setTrasparent(true);
|
2020-10-27 16:04:34 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
GWT.log("styles "+styles);
|
|
|
|
|
|
|
|
if(styles!=null && styles.size()>0){
|
2020-10-29 15:18:14 +01:00
|
|
|
layerItem.setHasLegend(true);
|
|
|
|
layerItem.setDefaultStyle(styles.get(0));
|
|
|
|
layerItem.setStyle(styles.get(0));
|
|
|
|
layerItem.setStyles(styles);
|
2020-10-27 16:04:34 +01:00
|
|
|
}else{
|
2020-11-12 18:25:24 +01:00
|
|
|
String style = URLUtil.getValueOfParameter("styles", wmsLink);
|
2020-10-27 16:04:34 +01:00
|
|
|
if(style!=null){ //CASE OF STYLE ="";
|
|
|
|
//TENTATIVE TO GET LEGEND
|
2020-10-29 15:18:14 +01:00
|
|
|
layerItem.setHasLegend(true);
|
2020-10-27 16:04:34 +01:00
|
|
|
}
|
|
|
|
}
|
2020-10-29 15:18:14 +01:00
|
|
|
GWT.log("Built layer: "+layerItem);
|
2020-11-13 16:37:34 +01:00
|
|
|
return layerItem;
|
2020-10-27 16:04:34 +01:00
|
|
|
}
|
2020-10-27 16:41:30 +01:00
|
|
|
|
2020-11-13 16:37:34 +01:00
|
|
|
|
2020-10-29 15:18:14 +01:00
|
|
|
/**
|
|
|
|
* Checks if is layer visible.
|
|
|
|
*
|
|
|
|
* @param layerItem the layer item
|
|
|
|
* @return true, if is layer visible
|
|
|
|
*/
|
|
|
|
public boolean isLayerVisible(LayerItem layerItem){
|
|
|
|
return olMap.isLayerVisible(layerItem.getName());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-10-27 16:41:30 +01:00
|
|
|
/**
|
|
|
|
* Sets the ol map.
|
|
|
|
*
|
|
|
|
* @param olMap the new ol map
|
|
|
|
*/
|
|
|
|
public void setOlMap(OpenLayerOSM olMap) {
|
|
|
|
this.olMap = olMap;
|
|
|
|
}
|
2020-10-29 15:18:14 +01:00
|
|
|
|
2020-11-12 18:25:24 +01:00
|
|
|
/**
|
|
|
|
* Gets the event bus.
|
|
|
|
*
|
|
|
|
* @return the event bus
|
|
|
|
*/
|
2020-10-29 15:18:14 +01:00
|
|
|
public HandlerManager getEventBus() {
|
|
|
|
return eventBus;
|
|
|
|
}
|
2020-11-12 18:25:24 +01:00
|
|
|
|
2020-10-27 16:04:34 +01:00
|
|
|
}
|