You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
592 lines
21 KiB
Java
592 lines
21 KiB
Java
/*
|
|
*
|
|
*/
|
|
package org.gcube.portlets.user.geoportaldataviewer.client;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
|
|
import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceContentDV;
|
|
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.events.AddedLayerToMapEvent;
|
|
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.QueryDataEventHandler;
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEvent;
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMinimumEvent;
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.events.ZoomOutOverMinimumEventHandler;
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM;
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.util.StringUtil;
|
|
import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil;
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaSpatialQueryResult;
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery;
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow;
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.PointsPath;
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest;
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.ZAxis;
|
|
|
|
import com.github.gwtbootstrap.client.ui.Button;
|
|
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
|
|
import com.google.gwt.core.client.GWT;
|
|
import com.google.gwt.core.client.Scheduler;
|
|
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
|
import com.google.gwt.event.dom.client.ClickEvent;
|
|
import com.google.gwt.event.dom.client.ClickHandler;
|
|
import com.google.gwt.event.shared.HandlerManager;
|
|
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;
|
|
import com.google.gwt.user.client.Window;
|
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
import com.google.gwt.user.client.ui.FlexTable;
|
|
import com.google.gwt.user.client.ui.HTML;
|
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
|
|
|
import ol.Coordinate;
|
|
|
|
/**
|
|
* 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;
|
|
|
|
private List<LayerObject> layerObjects = new ArrayList<LayerObject>();
|
|
|
|
private HandlerManager layerManagerBus = new HandlerManager("");
|
|
|
|
private HandlerManager applicationBus;
|
|
|
|
/**
|
|
* Instantiates a new layer manager.
|
|
*
|
|
* @param applicationBus the application bus
|
|
*/
|
|
public LayerManager(HandlerManager applicationBus) {
|
|
this.applicationBus = applicationBus;
|
|
bindEvents();
|
|
}
|
|
|
|
/**
|
|
* Bind events.
|
|
*/
|
|
private void bindEvents() {
|
|
|
|
layerManagerBus.addHandler(QueryDataEvent.TYPE, new QueryDataEventHandler() {
|
|
|
|
@Override
|
|
public void onQueryInteraction(final QueryDataEvent queryEvent) {
|
|
// GeoportalDataViewerConstants.print("fired QueryDataEvent:
|
|
// "+queryEvent.toString());
|
|
|
|
if (queryEvent.getGeoQuery() != null) {
|
|
GeoQuery selectDataInfo = queryEvent.getGeoQuery();
|
|
String mongoItemId = queryEvent.getMongoItemId();
|
|
|
|
GWT.log("(" + selectDataInfo.getX1() + "," + selectDataInfo.getY1() + ")(" + selectDataInfo.getX2()
|
|
+ "," + selectDataInfo.getY2() + ")");
|
|
|
|
for (LayerObject layerObj : layerObjects) {
|
|
// TODO
|
|
isLayerVisible(layerObj.getLayerItem());
|
|
|
|
}
|
|
|
|
BoundsMap mapBBOX = new BoundsMap();
|
|
// THIS IS SHOULD BE CORRET, THE BOUND AND CRS ARE READ FROM MAP
|
|
/*
|
|
* mapBBOX.setCrs(olMap.getProjectionCode());
|
|
* mapBBOX.setLowerLeftX(olMap.getExtent().getLowerLeftX());
|
|
* mapBBOX.setLowerLeftY(olMap.getExtent().getLowerLeftY());
|
|
* mapBBOX.setUpperRightX(olMap.getExtent().getUpperRightX());
|
|
* mapBBOX.setUpperRightY(olMap.getExtent().getUpperRightY());
|
|
*/
|
|
|
|
// THE FOLLOWING SHOULD BE NOT NEEDED BUT THE GETFEATURE WITH EPSG_3857 SEEMS
|
|
// NOT WORK IN OUR GEOSERVER
|
|
// double minX = olMap.getExtent().getLowerLeftX();
|
|
// double minY = olMap.getExtent().getLowerLeftY();
|
|
double minX = queryEvent.getGeoQuery().getX1();
|
|
double minY = queryEvent.getGeoQuery().getY1();
|
|
Coordinate centerCoordinate = new Coordinate(minX, minY);
|
|
centerCoordinate = olMap.transform(centerCoordinate, GeoportalDataViewerConstants.EPSG_3857,
|
|
GeoportalDataViewerConstants.EPSG_4326);
|
|
mapBBOX.setLowerLeftX(centerCoordinate.getX());
|
|
mapBBOX.setLowerLeftY(centerCoordinate.getY());
|
|
|
|
// double maxX = olMap.getExtent().getUpperRightX();
|
|
// double maxY = olMap.getExtent().getUpperRightY();
|
|
double maxX = queryEvent.getGeoQuery().getX2();
|
|
double maxY = queryEvent.getGeoQuery().getY2();
|
|
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);
|
|
GWT.log("MAX_WFS_FEATURES is: " + GeoportalDataViewerConstants.MAX_WFS_FEATURES);
|
|
// GeoportalDataViewerConstants.print("calling getDataResult");
|
|
|
|
GeoportalDataViewerServiceAsync.Util.getInstance().getDataResult(layerObjects,
|
|
olMap.getProjectionCode(), mapBBOX, GeoportalDataViewerConstants.MAX_WFS_FEATURES,
|
|
olMap.getCurrentZoomLevel(), new AsyncCallback<List<GeoNaSpatialQueryResult>>() {
|
|
|
|
@Override
|
|
public void onFailure(Throwable caught) {
|
|
// GeoportalDataViewerConstants.print("on Failure DataResult:
|
|
// "+caught.getMessage());
|
|
}
|
|
|
|
@Override
|
|
public void onSuccess(List<GeoNaSpatialQueryResult> listGeonaDataObjects) {
|
|
|
|
GWT.log("GeoNaDataObject's: " + listGeonaDataObjects);
|
|
// GeoportalDataViewerConstants.print("GeoNaDataObject's:
|
|
// "+listGeonaDataObjects);
|
|
|
|
if (listGeonaDataObjects == null || listGeonaDataObjects.isEmpty())
|
|
return;
|
|
|
|
FlexTable flex = new FlexTable();
|
|
flex.setCellPadding(1);
|
|
flex.setCellSpacing(1);
|
|
flex.getElement().addClassName("popup-table");
|
|
boolean featureFound = false;
|
|
FeatureRow feature = null;
|
|
|
|
// TODO SWTCH FOR EARCH ITEM TYPE
|
|
for (GeoNaSpatialQueryResult geoNaDataObject : listGeonaDataObjects) {
|
|
List<FeatureRow> features = geoNaDataObject.getFeatures();
|
|
|
|
// USING ONLY THE FIRST FEATURE IN THE LIST
|
|
if (features != null && features.size() > 0) {
|
|
String theProductId = null;
|
|
// I need to show exaclty the feature with produc_id == recordId
|
|
if (mongoItemId != null) {
|
|
for (FeatureRow fRow : features) {
|
|
List<String> productIdLst = fRow.getMapProperties()
|
|
.get("product_id");
|
|
theProductId = productIdLst.get(0);
|
|
try {
|
|
//long productId = Long.parseLong(thePID);
|
|
if (theProductId == mongoItemId) {
|
|
feature = fRow;
|
|
GWT.log("Found recorId == product_id with id: "
|
|
+ theProductId);
|
|
break;
|
|
}
|
|
} catch (Exception e) {
|
|
// TODO: handle exception
|
|
}
|
|
}
|
|
}
|
|
|
|
// If mongoItemId not passed, I'm using the first feature returned
|
|
if (mongoItemId == null) {
|
|
feature = features.get(0);
|
|
List<String> productIdLst = feature.getMapProperties()
|
|
.get("product_id");
|
|
theProductId = productIdLst.get(0);
|
|
} else {
|
|
// the recordId to show has been passed but not found into list of
|
|
// FeatureRow
|
|
if (feature == null) {
|
|
return;
|
|
}
|
|
}
|
|
|
|
GWT.log("the product id is: "+theProductId);
|
|
|
|
/*if(olMap.getCurrentZoomLevel()>10) {
|
|
GeoportalDataViewerServiceAsync.Util.getInstance().getLayersForId("concessione", theProductId, 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();
|
|
// li.setBaseLayer(false);
|
|
// li.setWmsLink(layer.getWmsLink());
|
|
// li.setTitle(layer.getLayerName());
|
|
// olMap.addWMSLayer(li);
|
|
}
|
|
|
|
}
|
|
});
|
|
return;
|
|
}*/
|
|
|
|
|
|
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;
|
|
// 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);
|
|
|
|
}
|
|
});
|
|
}
|
|
|
|
Coordinate centerTo = null;
|
|
|
|
if (feature.getGeometry() != null) {
|
|
|
|
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());
|
|
}
|
|
}
|
|
|
|
// 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);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
|
|
layerManagerBus.addHandler(AddedLayerToMapEvent.TYPE, new AddedLayerToMapEventHandler() {
|
|
|
|
@Override
|
|
public void onLayerRendered(AddedLayerToMapEvent addedLayerToMapEvent) {
|
|
GWT.log("Fired into layerManagerBus " + addedLayerToMapEvent);
|
|
applicationBus.fireEvent(addedLayerToMapEvent);
|
|
}
|
|
});
|
|
|
|
layerManagerBus.addHandler(ZoomOutOverMinimumEvent.TYPE, new ZoomOutOverMinimumEventHandler() {
|
|
|
|
@Override
|
|
public void onZoomOut(ZoomOutOverMinimumEvent zoomOutEvent) {
|
|
GWT.log("Fired into layerManagerBus " + zoomOutEvent);
|
|
applicationBus.fireEvent(zoomOutEvent);
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Parses the geona references.
|
|
*
|
|
* @param itemType the item type
|
|
* @param fRow the f row
|
|
* @return the show details event
|
|
*/
|
|
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) {
|
|
String productId = 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, productId, itemName, fRow);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
/**
|
|
* Adds the layer.
|
|
*
|
|
* @param geonaItemType the geona item type
|
|
* @param layerTitle the layer title
|
|
* @param layerName the layer name
|
|
* @param wmsLink the wms link
|
|
* @param isBase the is base
|
|
* @param displayInLayerSwitcher the display in layer switcher
|
|
* @param UUID the uuid
|
|
* @param onTop the on top
|
|
*/
|
|
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) {
|
|
|
|
// 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);
|
|
GeoportalDataViewerServiceAsync.Util.getInstance().parseWmsRequest(wmsLink, layerName,
|
|
new AsyncCallback<GeoInformationForWMSRequest>() {
|
|
|
|
@Override
|
|
public void onFailure(Throwable caught) {
|
|
|
|
Window.alert(caught.getMessage());
|
|
}
|
|
|
|
@Override
|
|
public void onSuccess(GeoInformationForWMSRequest geoInfoWMS) {
|
|
|
|
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());
|
|
|
|
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);
|
|
}
|
|
});
|
|
}
|
|
|
|
/**
|
|
* To layer item.
|
|
*
|
|
* @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
|
|
* @param wmsLink the wms link
|
|
* @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
|
|
* @return the layer item
|
|
*/
|
|
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) {
|
|
|
|
// GWT.log("Add addLayerByWms 1");
|
|
LayerItem layerItem = new LayerItem();
|
|
layerItem.setBaseLayer(isBase);
|
|
layerItem.setTitle(layerTitle);
|
|
layerItem.setName(layerName);
|
|
layerItem.setUrl(layerURL);
|
|
layerItem.setMapServerHost(mapServerHost);
|
|
// l.setExternal(isExternal);
|
|
layerItem.setOpacity(1d);
|
|
layerItem.setBuffer(2);
|
|
layerItem.setWmsLink(wmsLink);
|
|
layerItem.setWmsNotStandardParams(wmsNotStandardParams);
|
|
layerItem.setNcWms(isNcWms);
|
|
layerItem.setUUID(UUID);
|
|
layerItem.setZAxis(zAxis);
|
|
|
|
switch (layerType) {
|
|
|
|
// TODO IMPLEMENT THIS CASE
|
|
case RASTER_BASELAYER:
|
|
|
|
// l.setHasLegend(false);
|
|
layerItem.setBaseLayer(true);
|
|
layerItem.setTrasparent(false);
|
|
layerItem.setClickData(false);
|
|
break;
|
|
|
|
case FEATURE_TYPE:
|
|
|
|
// CASE FEATURE TYPE
|
|
layerItem.setBaseLayer(false);
|
|
layerItem.setClickData(true);
|
|
layerItem.setTrasparent(true);
|
|
break;
|
|
|
|
}
|
|
|
|
GWT.log("styles " + styles);
|
|
|
|
if (styles != null && styles.size() > 0) {
|
|
layerItem.setHasLegend(true);
|
|
layerItem.setDefaultStyle(styles.get(0));
|
|
layerItem.setStyle(styles.get(0));
|
|
layerItem.setStyles(styles);
|
|
} else {
|
|
String style = URLUtil.getValueOfParameter("styles", wmsLink);
|
|
if (style != null) { // CASE OF STYLE ="";
|
|
// TENTATIVE TO GET LEGEND
|
|
layerItem.setHasLegend(true);
|
|
}
|
|
}
|
|
GWT.log("Built layer: " + layerItem);
|
|
return layerItem;
|
|
}
|
|
|
|
/**
|
|
* 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());
|
|
}
|
|
|
|
/**
|
|
* Sets the ol map.
|
|
*
|
|
* @param olMap the new ol map
|
|
*/
|
|
public void setOlMap(OpenLayerOSM olMap) {
|
|
this.olMap = olMap;
|
|
}
|
|
|
|
/**
|
|
* Gets the layer manager bus.
|
|
*
|
|
* @return the layer manager bus
|
|
*/
|
|
public HandlerManager getLayerManagerBus() {
|
|
return layerManagerBus;
|
|
}
|
|
|
|
}
|