added download layer
This commit is contained in:
parent
6900a988f2
commit
30ab1b9185
|
@ -14,9 +14,6 @@ import com.google.gwt.i18n.client.DateTimeFormat;
|
||||||
*/
|
*/
|
||||||
public class GeoportalDataViewerConstants {
|
public class GeoportalDataViewerConstants {
|
||||||
|
|
||||||
// public static final String EPSG_4326 = "EPSG:4326";
|
|
||||||
// public static final String EPSG_3857 = "EPSG:3857";
|
|
||||||
|
|
||||||
public static final String MAP_DIV = "map";
|
public static final String MAP_DIV = "map";
|
||||||
|
|
||||||
public static final String GET_WMS_PARAMETER = "wmsrequest";
|
public static final String GET_WMS_PARAMETER = "wmsrequest";
|
||||||
|
@ -81,5 +78,24 @@ public class GeoportalDataViewerConstants {
|
||||||
public static native void printJs(String msg)/*-{
|
public static native void printJs(String msg)/*-{
|
||||||
console.log("js console: " + msg);
|
console.log("js console: " + msg);
|
||||||
}-*/;
|
}-*/;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints the.
|
||||||
|
*
|
||||||
|
* @param msg the msg
|
||||||
|
*/
|
||||||
|
public static native void printJsObj(Object object)/*-{
|
||||||
|
console.log("js obj: "+JSON.stringify(object, null, 4));
|
||||||
|
}-*/;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints the.
|
||||||
|
*
|
||||||
|
* @param msg the msg
|
||||||
|
*/
|
||||||
|
public static native String toJsonObj(Object object)/*-{
|
||||||
|
return JSON.stringify(object);
|
||||||
|
}-*/;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,14 +126,6 @@ public class OLMapManager {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// EPSG_4326_TO_ITALY
|
|
||||||
// Coordinate centerCoordinate = OLFactory.createCoordinate(GeoportalDataViewerConstants.ITALY_CENTER_LONG,
|
|
||||||
// GeoportalDataViewerConstants.ITALY_CENTER_LAT);
|
|
||||||
// Coordinate transformedCenterCoordinate = MapUtils.transformCoordiante(centerCoordinate,
|
|
||||||
// MAP_PROJECTION.EPSG_4326.getName(), MAP_PROJECTION.EPSG_3857.getName());
|
|
||||||
// olMap.setCenter(transformedCenterCoordinate);
|
|
||||||
// olMap.setZoom(GeoportalDataViewerConstants.MAP_ITALY_FIT_ZOOM_ON);
|
|
||||||
|
|
||||||
Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY);
|
Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY);
|
||||||
Coordinate transformedCenterCoordinate = italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857);
|
Coordinate transformedCenterCoordinate = italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857);
|
||||||
olMap.setCenter(transformedCenterCoordinate);
|
olMap.setCenter(transformedCenterCoordinate);
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
package org.gcube.portlets.user.geoportaldataviewer.client.gis;
|
package org.gcube.portlets.user.geoportaldataviewer.client.gis;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
|
import org.gcube.application.geoportalcommon.shared.gis.BoundsMap;
|
||||||
|
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
|
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.client.resources.Images;
|
import org.gcube.portlets.user.geoportaldataviewer.client.resources.Images;
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery;
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery;
|
||||||
|
@ -8,7 +13,12 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery.TYPE;
|
||||||
|
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.i18n.client.NumberFormat;
|
import com.google.gwt.i18n.client.NumberFormat;
|
||||||
|
import com.google.gwt.json.client.JSONObject;
|
||||||
|
import com.google.gwt.json.client.JSONParser;
|
||||||
|
import com.google.gwt.json.client.JSONString;
|
||||||
|
import com.google.gwt.json.client.JSONValue;
|
||||||
|
|
||||||
|
import ol.Collection;
|
||||||
import ol.Coordinate;
|
import ol.Coordinate;
|
||||||
import ol.Feature;
|
import ol.Feature;
|
||||||
import ol.Map;
|
import ol.Map;
|
||||||
|
@ -22,6 +32,7 @@ import ol.event.EventListener;
|
||||||
import ol.geom.Point;
|
import ol.geom.Point;
|
||||||
import ol.interaction.KeyboardPan;
|
import ol.interaction.KeyboardPan;
|
||||||
import ol.interaction.KeyboardZoom;
|
import ol.interaction.KeyboardZoom;
|
||||||
|
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;
|
||||||
|
@ -32,6 +43,7 @@ import ol.source.ImageWms;
|
||||||
import ol.source.ImageWmsOptions;
|
import ol.source.ImageWmsOptions;
|
||||||
import ol.source.ImageWmsParams;
|
import ol.source.ImageWmsParams;
|
||||||
import ol.source.Osm;
|
import ol.source.Osm;
|
||||||
|
import ol.source.Source;
|
||||||
import ol.source.XyzOptions;
|
import ol.source.XyzOptions;
|
||||||
import ol.style.Icon;
|
import ol.style.Icon;
|
||||||
import ol.style.IconOptions;
|
import ol.style.IconOptions;
|
||||||
|
@ -172,7 +184,7 @@ public class LightOpenLayerOSM {
|
||||||
*
|
*
|
||||||
* @param mapServerHost the map server host
|
* @param mapServerHost the map server host
|
||||||
* @param layerName the layer name
|
* @param layerName the layer name
|
||||||
* @param bbox
|
* @param bbox the bbox
|
||||||
* @return the image
|
* @return the image
|
||||||
*/
|
*/
|
||||||
public Image addWMSLayer(String mapServerHost, String layerName, BoundsMap bbox) {
|
public Image addWMSLayer(String mapServerHost, String layerName, BoundsMap bbox) {
|
||||||
|
@ -214,6 +226,83 @@ public class LightOpenLayerOSM {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the layers.
|
||||||
|
*
|
||||||
|
* @return the layers
|
||||||
|
*/
|
||||||
|
public List<String> getLayers() {
|
||||||
|
Collection<Base> layers = map.getLayers();
|
||||||
|
List<String> layerNames = null;
|
||||||
|
if (layers != null) {
|
||||||
|
Base[] layersArr = layers.getArray();
|
||||||
|
layerNames = new ArrayList<String>(layersArr.length);
|
||||||
|
for (int i = 0; i < layersArr.length; i++) {
|
||||||
|
Base layer = layersArr[i];
|
||||||
|
if (layer instanceof Image) {
|
||||||
|
Image layerImage = (Image) layer;
|
||||||
|
|
||||||
|
Source source = layerImage.getSource();
|
||||||
|
// GWT.log("source: "+source.toString());
|
||||||
|
GeoportalDataViewerConstants.printJsObj(source);
|
||||||
|
String sorceRootObj = GeoportalDataViewerConstants.toJsonObj(source);
|
||||||
|
JSONValue jsonObj = JSONParser.parseStrict(sorceRootObj);
|
||||||
|
// GWT.log("jsonObj: " + jsonObj.toString());
|
||||||
|
JSONObject jsonSourceObj = (JSONObject) jsonObj;
|
||||||
|
|
||||||
|
JSONObject jsonParamsObj = (JSONObject) jsonSourceObj.get("params_");
|
||||||
|
// GWT.log("jsonParamsObj is: "+jsonParamsObj);
|
||||||
|
JSONValue jsonLayers = jsonParamsObj.get("LAYERS");
|
||||||
|
GWT.log("theLayerName name is: " + jsonLayers);
|
||||||
|
layerNames.add(jsonLayers.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return layerNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
public java.util.Map<String, String> getLayerURLsProperty() {
|
||||||
|
|
||||||
|
Collection<Base> layers = map.getLayers();
|
||||||
|
java.util.Map<String, String> mapLayerNameURL = new HashMap<String, String>();
|
||||||
|
if (layers != null) {
|
||||||
|
Base[] layersArr = layers.getArray();
|
||||||
|
for (int i = 0; i < layersArr.length; i++) {
|
||||||
|
Base layer = layersArr[i];
|
||||||
|
// GeoportalDataViewerConstants.printJsObj(layer);
|
||||||
|
if (layer instanceof Image) {
|
||||||
|
Image layerImage = (Image) layer;
|
||||||
|
|
||||||
|
Source source = layerImage.getSource();
|
||||||
|
// GWT.log("source: "+source.toString());
|
||||||
|
// GeoportalDataViewerConstants.printJsObj(source);
|
||||||
|
String sorceRootObj = GeoportalDataViewerConstants.toJsonObj(source);
|
||||||
|
JSONValue jsonObj = JSONParser.parseStrict(sorceRootObj);
|
||||||
|
// GWT.log("jsonObj: " + jsonObj.toString());
|
||||||
|
JSONObject jsonSourceObj = (JSONObject) jsonObj;
|
||||||
|
|
||||||
|
JSONObject jsonParamsObj = (JSONObject) jsonSourceObj.get("params_");
|
||||||
|
// GWT.log("jsonParamsObj is: "+jsonParamsObj);
|
||||||
|
JSONString jsonLayers = (JSONString) jsonParamsObj.get("LAYERS");
|
||||||
|
String layerName = jsonLayers.stringValue();
|
||||||
|
GWT.log("jsonLayers is: " + layerName);
|
||||||
|
// GWT.log("theLayerName name is: " + jsonLayers);
|
||||||
|
|
||||||
|
JSONValue jsonImage = jsonSourceObj.get("image_");
|
||||||
|
// GWT.log("jsonImage: " + jsonImage.toString());
|
||||||
|
JSONObject jsonImageObj = (JSONObject) jsonImage;
|
||||||
|
JSONString jsonSrc = (JSONString) jsonImageObj.get("src_");
|
||||||
|
String layerURL = jsonSrc.stringValue();
|
||||||
|
GWT.log("jsonSrc: " + layerURL);
|
||||||
|
mapLayerNameURL.put(layerName, layerURL);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GWT.log("returning mapLayerNameURL: "+mapLayerNameURL);
|
||||||
|
return mapLayerNameURL;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the point.
|
* Adds the point.
|
||||||
*
|
*
|
||||||
|
|
|
@ -403,8 +403,12 @@ public abstract class OpenLayerOSM {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the all detail layers.
|
||||||
|
*/
|
||||||
public void removeAllDetailLayers() {
|
public void removeAllDetailLayers() {
|
||||||
|
|
||||||
|
//NOT NEEDED ANYMORE.. I'M USING MIN/MAX LAYER RESOLUTION
|
||||||
|
|
||||||
/*
|
/*
|
||||||
if (wmsDetailsLayerMap == null)
|
if (wmsDetailsLayerMap == null)
|
||||||
|
@ -422,32 +426,6 @@ public abstract class OpenLayerOSM {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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.
|
* Adds the vector.
|
||||||
*
|
*
|
||||||
|
@ -588,7 +566,7 @@ public abstract class OpenLayerOSM {
|
||||||
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: " + theLayerName);
|
||||||
if (theLayerName != null && theLayerName.equals(layerName))
|
if (theLayerName != null && theLayerName.equals(layerName))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -596,6 +574,32 @@ public abstract class OpenLayerOSM {
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the layer property.
|
||||||
|
*
|
||||||
|
* @param layerName the layer name
|
||||||
|
* @param property the property
|
||||||
|
* @return the layer property
|
||||||
|
*/
|
||||||
|
public String getLayerProperty(String layerName, String property) {
|
||||||
|
|
||||||
|
Collection<Base> layers = map.getLayers();
|
||||||
|
|
||||||
|
if (layers != null) {
|
||||||
|
Base[] layersArr = layers.getArray();
|
||||||
|
for (int i = 0; i < layersArr.length; i++) {
|
||||||
|
Base layer = layersArr[i];
|
||||||
|
String theLayerName = (String) layer.get("name");
|
||||||
|
GWT.log("The Layer name is: " + layerName);
|
||||||
|
if (theLayerName != null && theLayerName.equals(layerName))
|
||||||
|
return layer.get(property);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the projection code.
|
* Gets the projection code.
|
||||||
|
|
|
@ -23,14 +23,14 @@ import com.google.gwt.user.client.ui.Widget;
|
||||||
import ol.Coordinate;
|
import ol.Coordinate;
|
||||||
import ol.OLFactory;
|
import ol.OLFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class MapView.
|
* The Class MapView.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
*
|
*
|
||||||
* Nov 11, 2020
|
* Nov 11, 2020
|
||||||
*/
|
*/
|
||||||
public class MapView extends Composite{
|
public class MapView extends Composite {
|
||||||
|
|
||||||
private static MapViewUiBinder uiBinder = GWT.create(MapViewUiBinder.class);
|
private static MapViewUiBinder uiBinder = GWT.create(MapViewUiBinder.class);
|
||||||
|
|
||||||
|
@ -39,55 +39,47 @@ 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 11, 2020
|
* Nov 11, 2020
|
||||||
*/
|
*/
|
||||||
interface MapViewUiBinder extends UiBinder<Widget, MapView> {
|
interface MapViewUiBinder extends UiBinder<Widget, MapView> {
|
||||||
}
|
}
|
||||||
|
|
||||||
@UiField
|
@UiField
|
||||||
HTMLPanel theMap;
|
HTMLPanel theMap;
|
||||||
|
|
||||||
@UiField
|
@UiField
|
||||||
HorizontalPanel coordinatePanel;
|
HorizontalPanel coordinatePanel;
|
||||||
|
|
||||||
private LightOpenLayerOSM olsm;
|
private LightOpenLayerOSM lightOLSM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new map view.
|
* Instantiates a new map view.
|
||||||
*
|
*
|
||||||
* @param centerTo the center to
|
* @param centerTo the center to
|
||||||
* @param zoom the zoom
|
* @param zoom the zoom
|
||||||
*/
|
*/
|
||||||
public MapView(Coordinate centerTo, int zoom, String internalMapWidth, String internalMapHeight) {
|
public MapView(Coordinate centerTo, int zoom, String internalMapWidth, String internalMapHeight) {
|
||||||
initWidget(uiBinder.createAndBindUi(this));
|
initWidget(uiBinder.createAndBindUi(this));
|
||||||
String theMapId = "map"+Random.nextInt();
|
String theMapId = "map" + Random.nextInt();
|
||||||
theMap.getElement().setId(theMapId);
|
theMap.getElement().setId(theMapId);
|
||||||
theMap.setWidth(internalMapWidth);
|
theMap.setWidth(internalMapWidth);
|
||||||
theMap.setHeight(internalMapHeight);
|
theMap.setHeight(internalMapHeight);
|
||||||
|
|
||||||
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
olsm = new LightOpenLayerOSM(theMapId);
|
lightOLSM = new LightOpenLayerOSM(theMapId);
|
||||||
|
|
||||||
//EPSG_3857 LOCATION TO ITALY
|
// EPSG_3857 LOCATION TO ITALY
|
||||||
Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY);
|
Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY);
|
||||||
Coordinate transformedCenterCoordinate = italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857);
|
Coordinate transformedCenterCoordinate = italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857);
|
||||||
olsm.setCenter(transformedCenterCoordinate);
|
lightOLSM.setCenter(transformedCenterCoordinate);
|
||||||
olsm.setZoom(GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON);
|
lightOLSM.setZoom(GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON);
|
||||||
|
|
||||||
// Coordinate centerCoordinate = OLFactory.createCoordinate(GeoportalDataViewerConstants.ITALY_CENTER_LONG, GeoportalDataViewerConstants.ITALY_CENTER_LAT);
|
|
||||||
// Coordinate transformedCenterCoordinate = MapUtils.transformCoordiante(centerCoordinate, GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857);
|
|
||||||
// olsm.setCenter(transformedCenterCoordinate);
|
|
||||||
// olsm.setZoom(GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON);
|
|
||||||
|
|
||||||
//setMapSize();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setMapSize() {
|
private void setMapSize() {
|
||||||
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||||
|
|
||||||
|
@ -95,38 +87,38 @@ import ol.OLFactory;
|
||||||
public void execute() {
|
public void execute() {
|
||||||
int width = theMap.getParent().getOffsetWidth();
|
int width = theMap.getParent().getOffsetWidth();
|
||||||
int height = theMap.getParent().getOffsetHeight();
|
int height = theMap.getParent().getOffsetHeight();
|
||||||
if(width==0)
|
if (width == 0)
|
||||||
width = 300;
|
width = 300;
|
||||||
|
|
||||||
if(height==0)
|
if (height == 0)
|
||||||
height = 300;
|
height = 300;
|
||||||
|
|
||||||
GWT.log("Internal Map w: "+width + ", h: "+height);
|
GWT.log("Internal Map w: " + width + ", h: " + height);
|
||||||
theMap.setSize(width+"px", height+"px");
|
theMap.setSize(width + "px", height + "px");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the marker.
|
* Adds the marker.
|
||||||
*
|
*
|
||||||
* @param coordinate the coordinate
|
* @param coordinate the coordinate
|
||||||
* @param showCoordinateText the show coordinate text
|
* @param showCoordinateText the show coordinate text
|
||||||
*/
|
*/
|
||||||
public void addMarker(Coordinate coordinate, boolean showCoordinateText) {
|
public void addMarker(Coordinate coordinate, boolean showCoordinateText) {
|
||||||
|
|
||||||
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
if(olsm!=null) {
|
if (lightOLSM != null) {
|
||||||
olsm.addPoint(coordinate, showCoordinateText, true);
|
lightOLSM.addPoint(coordinate, showCoordinateText, true);
|
||||||
olsm.getMap().getView().setCenter(coordinate);
|
lightOLSM.getMap().getView().setCenter(coordinate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the WMS layer.
|
* Adds the WMS layer.
|
||||||
*
|
*
|
||||||
|
@ -139,12 +131,12 @@ import ol.OLFactory;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
|
|
||||||
ExtentWrapped ew = null;
|
ExtentWrapped ew = null;
|
||||||
BoundsMap theBBOX = bbox;
|
BoundsMap theBBOX = bbox;
|
||||||
|
|
||||||
if (bbox != null) {
|
if (bbox != null) {
|
||||||
|
|
||||||
Coordinate lower = OLFactory.createCoordinate(bbox.getLowerLeftX(), bbox.getLowerLeftY());
|
Coordinate lower = OLFactory.createCoordinate(bbox.getLowerLeftX(), bbox.getLowerLeftY());
|
||||||
Coordinate lowerCoord = MapUtils.transformCoordiante(lower, MAP_PROJECTION.EPSG_4326.getName(),
|
Coordinate lowerCoord = MapUtils.transformCoordiante(lower, MAP_PROJECTION.EPSG_4326.getName(),
|
||||||
MAP_PROJECTION.EPSG_3857.getName());
|
MAP_PROJECTION.EPSG_3857.getName());
|
||||||
|
@ -152,22 +144,27 @@ import ol.OLFactory;
|
||||||
Coordinate upper = OLFactory.createCoordinate(bbox.getUpperRightX(), bbox.getUpperRightY());
|
Coordinate upper = OLFactory.createCoordinate(bbox.getUpperRightX(), bbox.getUpperRightY());
|
||||||
Coordinate upperCoord = MapUtils.transformCoordiante(upper, MAP_PROJECTION.EPSG_4326.getName(),
|
Coordinate upperCoord = MapUtils.transformCoordiante(upper, MAP_PROJECTION.EPSG_4326.getName(),
|
||||||
MAP_PROJECTION.EPSG_3857.getName());
|
MAP_PROJECTION.EPSG_3857.getName());
|
||||||
|
|
||||||
ew = new ExtentWrapped(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(), upperCoord.getY());
|
ew = new ExtentWrapped(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(), upperCoord.getY());
|
||||||
theBBOX = new BoundsMap(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(), upperCoord.getY(), null);
|
theBBOX = new BoundsMap(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(), upperCoord.getY(),
|
||||||
|
null);
|
||||||
}
|
}
|
||||||
|
|
||||||
olsm.addWMSLayer(mapServerHost, layerName, theBBOX);
|
lightOLSM.addWMSLayer(mapServerHost, layerName, theBBOX);
|
||||||
|
|
||||||
if (ew != null) {
|
if (ew != null) {
|
||||||
|
|
||||||
olsm.getMap().getView().fit(ew);
|
lightOLSM.getMap().getView().fit(ew);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LightOpenLayerOSM getLightOLSM() {
|
||||||
|
return lightOLSM;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -266,16 +266,16 @@ public class ConcessioneView extends Composite {
|
||||||
if(listLayersDV==null)
|
if(listLayersDV==null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (LayerConcessioneDV layer : listLayersDV) {
|
for (LayerConcessioneDV layerDV : listLayersDV) {
|
||||||
|
|
||||||
if(layer.getPolicy()==null || layer.getPolicy().equalsIgnoreCase("OPEN")) {
|
if(layerDV.getPolicy()==null || layerDV.getPolicy().equalsIgnoreCase("OPEN")) {
|
||||||
piantaFineScavoPanel.setVisible(true);
|
piantaFineScavoPanel.setVisible(true);
|
||||||
piantaFineScavoPanel.add(new LayerConcessioneView(layer));
|
piantaFineScavoPanel.add(new LayerConcessioneView(layerDV));
|
||||||
}else {
|
}else {
|
||||||
//I need to be authenticated to show the fields according to POLICY
|
//I need to be authenticated to show the fields according to POLICY
|
||||||
if(myLogin!=null) {
|
if(myLogin!=null) {
|
||||||
piantaFineScavoPanel.setVisible(true);
|
piantaFineScavoPanel.setVisible(true);
|
||||||
piantaFineScavoPanel.add(new LayerConcessioneView(layer));
|
piantaFineScavoPanel.add(new LayerConcessioneView(layerDV));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package org.gcube.portlets.user.geoportaldataviewer.client.ui.products.concessioni;
|
package org.gcube.portlets.user.geoportaldataviewer.client.ui.products.concessioni;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV;
|
import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV;
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
|
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
|
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
|
||||||
|
@ -8,11 +10,15 @@ import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.L
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.PLACE;
|
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.PLACE;
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.MapView;
|
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.MapView;
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.client.ui.util.CustomFlexTable;
|
import org.gcube.portlets.user.geoportaldataviewer.client.ui.util.CustomFlexTable;
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil;
|
|
||||||
|
|
||||||
|
import com.github.gwtbootstrap.client.ui.DropdownButton;
|
||||||
|
import com.github.gwtbootstrap.client.ui.NavLink;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
import com.google.gwt.uibinder.client.UiBinder;
|
import com.google.gwt.uibinder.client.UiBinder;
|
||||||
import com.google.gwt.uibinder.client.UiField;
|
import com.google.gwt.uibinder.client.UiField;
|
||||||
|
import com.google.gwt.user.client.Window;
|
||||||
import com.google.gwt.user.client.ui.Composite;
|
import com.google.gwt.user.client.ui.Composite;
|
||||||
import com.google.gwt.user.client.ui.HTML;
|
import com.google.gwt.user.client.ui.HTML;
|
||||||
import com.google.gwt.user.client.ui.HTMLPanel;
|
import com.google.gwt.user.client.ui.HTMLPanel;
|
||||||
|
@ -49,10 +55,6 @@ public class LayerConcessioneView extends Composite {
|
||||||
GWT.log("WMS LINK: " + layerDV.getWmsLink());
|
GWT.log("WMS LINK: " + layerDV.getWmsLink());
|
||||||
if (layerDV.getLayerName() != null && layerDV.getWmsLink() != null) {
|
if (layerDV.getLayerName() != null && layerDV.getWmsLink() != null) {
|
||||||
|
|
||||||
String pngWMSLink = URLUtil.setValueOfParameter("FORMAT", layerDV.getWmsLink(), "image/png", true);
|
|
||||||
|
|
||||||
customTable.addNextKeyWidget("Layer", new HTML("<a href=\"" + pngWMSLink + "\">download image</a>"));
|
|
||||||
|
|
||||||
Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY);
|
Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY);
|
||||||
Coordinate transformedCenterCoordinate = italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857);
|
Coordinate transformedCenterCoordinate = italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857);
|
||||||
// Coordinate centerCoordinate = OLFactory.createCoordinate(GeoportalDataViewerConstants.ITALY_CENTER_LONG, GeoportalDataViewerConstants.ITALY_CENTER_LAT);
|
// Coordinate centerCoordinate = OLFactory.createCoordinate(GeoportalDataViewerConstants.ITALY_CENTER_LONG, GeoportalDataViewerConstants.ITALY_CENTER_LAT);
|
||||||
|
@ -64,8 +66,72 @@ public class LayerConcessioneView extends Composite {
|
||||||
String mapServerHost = layerDV.getWmsLink().contains("?")
|
String mapServerHost = layerDV.getWmsLink().contains("?")
|
||||||
? layerDV.getWmsLink().substring(0, layerDV.getWmsLink().indexOf("?"))
|
? layerDV.getWmsLink().substring(0, layerDV.getWmsLink().indexOf("?"))
|
||||||
: layerDV.getWmsLink();
|
: layerDV.getWmsLink();
|
||||||
|
|
||||||
|
DropdownButton downloadButt = new DropdownButton("download as...");
|
||||||
|
NavLink navLink = new NavLink("PNG");
|
||||||
|
HTML html = new HTML("<a id=\"image-download\" download=\"map.png\"></a>");
|
||||||
|
navLink.getElement().appendChild(html.getElement());
|
||||||
|
navLink.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
|
Map<String, String> mapLayerURLs = mapView.getLightOLSM().getLayerURLsProperty();
|
||||||
|
|
||||||
|
String layerURL = mapLayerURLs.get(layerDV.getLayerName());
|
||||||
|
GWT.log("layerDV name is: " + layerDV.getLayerName());
|
||||||
|
if (layerURL != null)
|
||||||
|
Window.open(layerURL, "_blank", null);
|
||||||
|
|
||||||
|
//downloadMap(mapView.getLightOLSM().getMap());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
downloadButt.add(navLink);
|
||||||
|
customTable.addNextKeyWidget("Layer", downloadButt);
|
||||||
mapView.addWMSLayer(mapServerHost, layerDV.getLayerName(), layerDV.getBbox());
|
mapView.addWMSLayer(mapServerHost, layerDV.getLayerName(), layerDV.getBbox());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prints the.
|
||||||
|
*
|
||||||
|
* @param msg the msg
|
||||||
|
*/
|
||||||
|
public static native void downloadMap(ol.Map map)/*-{
|
||||||
|
console.log("map: " + map);
|
||||||
|
map.once('rendercomplete', function() {
|
||||||
|
var mapCanvas = document.createElement('canvas');
|
||||||
|
var size = map.getSize();
|
||||||
|
mapCanvas.width = size[0];
|
||||||
|
mapCanvas.height = size[1];
|
||||||
|
var mapContext = mapCanvas.getContext('2d');
|
||||||
|
Array.prototype.forEach.call(document
|
||||||
|
.querySelectorAll('.ol-layer canvas'), function(canvas) {
|
||||||
|
if (canvas.width > 0) {
|
||||||
|
var opacity = canvas.parentNode.style.opacity;
|
||||||
|
mapContext.globalAlpha = opacity === '' ? 1
|
||||||
|
: Number(opacity);
|
||||||
|
var transform = canvas.style.transform;
|
||||||
|
// Get the transform parameters from the style's transform matrix
|
||||||
|
var matrix = transform.match(/^matrix\(([^\(]*)\)$/)[1]
|
||||||
|
.split(',').map(Number);
|
||||||
|
// Apply the transform to the export map context
|
||||||
|
CanvasRenderingContext2D.prototype.setTransform.apply(
|
||||||
|
mapContext, matrix);
|
||||||
|
mapContext.drawImage(canvas, 0, 0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (navigator.msSaveBlob) {
|
||||||
|
// link download attribute does not work on MS browsers
|
||||||
|
navigator.msSaveBlob(mapCanvas.msToBlob(), 'map.png');
|
||||||
|
} else {
|
||||||
|
console.log('qui');
|
||||||
|
// var link = document.getElementById('image-download');
|
||||||
|
// link.href = mapCanvas.toDataURL();
|
||||||
|
window.open(mapCanvas.toDataURL(),'_blank');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
map.renderSync();
|
||||||
|
}-*/;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue