added MAP_PROJECTION object

This commit is contained in:
Francesco Mangiacrapa 2021-09-01 12:51:06 +02:00
parent b2e6830bbe
commit b337955f71
16 changed files with 491 additions and 182 deletions

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.products.ConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.model.RecordDV;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
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.AddedLayerToMapEventHandler;
@ -335,7 +336,7 @@ public class GeoportalDataViewer implements EntryPoint {
Double y = concessioneDV.getCentroidLat();
GWT.log("X: "+x +", Y:"+y);
if(x!=null && y!=null) {
Coordinate transfCoord = MapUtils.transformCoordiante(new Coordinate(x, y), GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857);
Coordinate transfCoord = MapUtils.transformCoordiante(new Coordinate(x, y), MAP_PROJECTION.EPSG_4326.getName(), MAP_PROJECTION.EPSG_3857.getName());
GeoQuery select = olMapMng.toDataPointQuery(transfCoord,false);
GWT.log("GeoQuery: "+select);
//GeoportalDataViewerConstants.print("fireEvent QueryDataEvent");

View File

@ -10,15 +10,15 @@ import com.google.gwt.i18n.client.DateTimeFormat;
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 24, 2020
* Nov 24, 2020
*/
public class GeoportalDataViewerConstants {
public static final String EPSG_4326 = "EPSG:4326";
public static final String EPSG_3857 = "EPSG:3857";
// 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 GET_WMS_PARAMETER = "wmsrequest";
public static final String GET_GEONA_ITEM_TYPE = "git";
public static final String GET_GEONA_ITEM_ID = "gid";
@ -27,32 +27,51 @@ public class GeoportalDataViewerConstants {
public static final String GET_MAX_ZOOM_LEVEL = OpenLayersMapParameters.OL_MAP_PARAM.maxzoomlevel.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 enum MapEventType {INIT, MAP_ZOOM_END, MOVE_END, ADDED_LAYER_TO_MAP}
public static enum MapEventType {
INIT, MAP_ZOOM_END, MOVE_END, ADDED_LAYER_TO_MAP
}
/**
* The Enum LayerType.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 24, 2020
* Nov 24, 2020
*/
public enum LayerType {RASTER_BASELAYER, FEATURE_TYPE};
public static final int MAX_WFS_FEATURES = 3; // zero for no limit
public static final String NEW_LINE_BR = "<br/>";
public static final double ITALY_CENTER_LONG = 12.45;
public static final double ITALY_CENTER_LAT = 42.98;
public static final int LIGHT_MAP_ITALY_FIT_ZOOM_ON = 5;
public static final int MAP_ITALY_FIT_ZOOM_ON = 6;
public enum LayerType {
RASTER_BASELAYER, FEATURE_TYPE
};
public static DateTimeFormat DT_FORMAT = DateTimeFormat.getFormat(ConvertToDataViewModel.DATE_FORMAT);
public static final int MAX_WFS_FEATURES = 3; // zero for no limit
public static final String NEW_LINE_BR = "<br/>";
public static enum MAP_PROJECTION {
EPSG_4326("EPSG:4326"), EPSG_3857("EPSG:3857");
String name;
MAP_PROJECTION(String name) {
this.name = name;
}
public String getName() {
return name;
}
}
public static final double ITALY_CENTER_LONG = 12.45;
public static final double ITALY_CENTER_LAT = 42.98;
public static final int LIGHT_MAP_ITALY_FIT_ZOOM_ON = 5;
public static final int MAP_ITALY_FIT_ZOOM_ON = 6;
/**
* Prints the.
@ -60,8 +79,7 @@ public class GeoportalDataViewerConstants {
* @param msg the msg
*/
public static native void printJs(String msg)/*-{
console.log("js console: "+msg);
console.log("js console: " + msg);
}-*/;
}

View File

@ -13,7 +13,7 @@ import org.gcube.application.geoportalcommon.shared.products.content.WorkspaceCo
import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV;
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.MapEventType;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
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;
@ -123,8 +123,8 @@ public class LayerManager {
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);
centerCoordinate = olMap.transform(centerCoordinate, MAP_PROJECTION.EPSG_3857.getName(),
MAP_PROJECTION.EPSG_4326.getName());
mapBBOX.setLowerLeftX(centerCoordinate.getX());
mapBBOX.setLowerLeftY(centerCoordinate.getY());
@ -133,12 +133,12 @@ public class LayerManager {
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);
centerCoordinate = olMap.transform(centerCoordinate, MAP_PROJECTION.EPSG_3857.getName(),
MAP_PROJECTION.EPSG_4326.getName());
mapBBOX.setUpperRightX(centerCoordinate.getX());
mapBBOX.setUpperRightY(centerCoordinate.getY());
mapBBOX.setCrs(GeoportalDataViewerConstants.EPSG_4326);
mapBBOX.setCrs(MAP_PROJECTION.EPSG_4326.getName());
GWT.log("Bounds is: " + mapBBOX);
GWT.log("MAX_WFS_FEATURES is: " + GeoportalDataViewerConstants.MAX_WFS_FEATURES);
@ -254,10 +254,10 @@ public class LayerManager {
olMap.removeAllDetailLayers();
}
if(queryEvent.getSourceMapEventType() != null && queryEvent.getSourceMapEventType().equals(MapEventType.MAP_ZOOM_END)) {
GWT.log("EVENT IS "+MapEventType.MAP_ZOOM_END +" retuning");
return;
}
// 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();
@ -412,6 +412,7 @@ public class LayerManager {
@Override
public void onZoomOut(ZoomOutOverMinimumEvent zoomOutEvent) {
GWT.log("Fired into layerManagerBus " + zoomOutEvent);
olMap.removeAllDetailLayers();
applicationBus.fireEvent(zoomOutEvent);
}
});

View File

@ -1,11 +1,15 @@
package org.gcube.portlets.user.geoportaldataviewer.client;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
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.ZoomOutOverMinimumEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.ExtentWrapped;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.Location;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.PLACE;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery.TYPE;
@ -15,7 +19,6 @@ import com.google.gwt.event.shared.HandlerManager;
import ol.Coordinate;
import ol.MapBrowserEvent;
import ol.MapEvent;
import ol.OLFactory;
/**
* The Class OLMapManager.
@ -121,13 +124,17 @@ public class OLMapManager {
};
// EPSG_4326_TO_ITALY
Coordinate centerCoordinate = OLFactory.createCoordinate(GeoportalDataViewerConstants.ITALY_CENTER_LONG,
GeoportalDataViewerConstants.ITALY_CENTER_LAT);
Coordinate transformedCenterCoordinate = MapUtils.transformCoordiante(centerCoordinate,
GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857);
// 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);
Coordinate transformedCenterCoordinate = italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857);
olMap.setCenter(transformedCenterCoordinate);
olMap.setZoom(GeoportalDataViewerConstants.MAP_ITALY_FIT_ZOOM_ON);
olMap.setZoom(italyLocation.getZoomLevel());
}

View File

@ -0,0 +1,52 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.Location;
import com.google.gwt.event.shared.GwtEvent;
/**
* The Class MapExtentToEvent.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Sep 1, 2021
*/
public class MapExtentToEvent extends GwtEvent<MapExtentToEventHandler> {
public static Type<MapExtentToEventHandler> TYPE = new Type<MapExtentToEventHandler>();
private Location location;
/**
* Instantiates a new map extent to event.
*
* @param layerItem the layer item
*/
public MapExtentToEvent(Location location) {
this.location = location;
}
/**
* Gets the associated type.
*
* @return the associated type
*/
@Override
public Type<MapExtentToEventHandler> getAssociatedType() {
return TYPE;
}
/**
* Dispatch.
*
* @param handler the handler
*/
@Override
protected void dispatch(MapExtentToEventHandler handler) {
handler.onExtentEvent(this);
}
public Location getLocation() {
return location;
}
}

View File

@ -0,0 +1,20 @@
package org.gcube.portlets.user.geoportaldataviewer.client.events;
import com.google.gwt.event.shared.EventHandler;
/**
* The Interface MapExtentToEventHandler.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Sep 1, 2021
*/
public interface MapExtentToEventHandler extends EventHandler {
/**
* On extent event.
*
* @param mapExtentToEvent the map extent to event
*/
void onExtentEvent(MapExtentToEvent mapExtentToEvent);
}

View File

@ -1,7 +1,7 @@
package org.gcube.portlets.user.geoportaldataviewer.client.gis;
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.resources.Images;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery.TYPE;
@ -39,34 +39,33 @@ import ol.style.Style;
import ol.style.Text;
import ol.style.TextOptions;
/**
* The Class LightOpenLayerOSM.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 11, 2020
*/
public class LightOpenLayerOSM {
/**
* The Class LightOpenLayerOSM.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 11, 2020
*/
public class LightOpenLayerOSM {
/** The map. */
private Map map;
/** The view. */
private View view;
/** The view options. */
private ViewOptions viewOptions = OLFactory.createOptions();
/** The projection options. */
private ProjectionOptions projectionOptions = OLFactory.createOptions();
private boolean isQueryPointActive;
private ol.layer.Vector geometryLayer;
private String markerURL = Images.ICONS.mapMarkerIcon().getURL();
/**
* Instantiates a new light open layer OSM.
*
@ -74,123 +73,122 @@ import ol.style.TextOptions;
*/
public LightOpenLayerOSM(String divTargetId) {
// create a OSM-layer
XyzOptions osmSourceOptions = OLFactory.createOptions();
// create a OSM-layer
XyzOptions osmSourceOptions = OLFactory.createOptions();
Osm osmSource = new Osm(osmSourceOptions);
LayerOptions osmLayerOptions = OLFactory.createOptions();
osmLayerOptions.setSource(osmSource);
Osm osmSource = new Osm(osmSourceOptions);
LayerOptions osmLayerOptions = OLFactory.createOptions();
osmLayerOptions.setSource(osmSource);
Tile osmLayer = new Tile(osmLayerOptions);
Tile osmLayer = new Tile(osmLayerOptions);
// create a projection
projectionOptions.setCode(GeoportalDataViewerConstants.EPSG_3857);
projectionOptions.setCode(MAP_PROJECTION.EPSG_3857.getName());
projectionOptions.setUnits("m");
Projection projection = new Projection(projectionOptions);
viewOptions.setProjection(projection);
viewOptions.setMaxZoom(20);
// create a view
view = new View(viewOptions);
// create the map
MapOptions mapOptions = OLFactory.createOptions();
mapOptions.setTarget(divTargetId);
mapOptions.setView(view);
// create a view
view = new View(viewOptions);
map = new Map(mapOptions);
// create the map
MapOptions mapOptions = OLFactory.createOptions();
mapOptions.setTarget(divTargetId);
mapOptions.setView(view);
map.addLayer(osmLayer);
//map.addLayer(tileDebugLayer);
map = new Map(mapOptions);
map.addLayer(osmLayer);
// map.addLayer(tileDebugLayer);
Attribution attribution = new Attribution();
attribution.setCollapsed(true);
map.addClickListener(new EventListener<MapBrowserEvent>() {
Attribution attribution = new Attribution();
attribution.setCollapsed(true);
map.addClickListener(new EventListener<MapBrowserEvent>() {
@Override
public void onEvent(MapBrowserEvent event) {
// TODO Auto-generated method stub
Coordinate coordinate = event.getCoordinate();
if(isQueryPointActive) {
if (isQueryPointActive) {
double lon = coordinate.getX();
double lat = coordinate.getY();
int w = (int) map.getSize().getWidth();
int h = (int) map.getSize().getHeight();
// handler.clickOnMap(x, y, w, h);
// ratio - mapPixelWeight : bboxWeight = 10px : geoRectangleWidth
// handler.clickOnMap(x, y, w, h);
// ratio - mapPixelWeight : bboxWeight = 10px : geoRectangleWidth
// where 10px is the pixel diameter dimension of the clicked point
double bboxWidth = Math.abs(getExtent().getLowerLeftX() - getExtent().getUpperRightX());
double geoWidth = (bboxWidth / w) * (20 / 2);
double x1 = Math.min(lon+geoWidth, lon-geoWidth);
double x2 = Math.max(lon+geoWidth, lon-geoWidth);
double y1 = Math.min(lat+geoWidth, lat-geoWidth);
double y2 = Math.max(lat+geoWidth, lat-geoWidth);
//GWT.log("("+x1+","+y1+")("+x2+","+y2+")");
double x1 = Math.min(lon + geoWidth, lon - geoWidth);
double x2 = Math.max(lon + geoWidth, lon - geoWidth);
double y1 = Math.min(lat + geoWidth, lat - geoWidth);
double y2 = Math.max(lat + geoWidth, lat - geoWidth);
// GWT.log("("+x1+","+y1+")("+x2+","+y2+")");
// Point pt = new Point(coordinate);
// ol.Extent extent = pt.getExtent();
// //new ClickDataInfo(x1, y1, x2, y2)
// SelectDataInfo selectDataInfo
//selectBox(new GeoQuery(x1, y1, x2, y2, GeoQuery.TYPE.POINT));
// selectBox(new GeoQuery(x1, y1, x2, y2, GeoQuery.TYPE.POINT));
GeoQuery select = new GeoQuery(x1, y1, x2, y2, TYPE.POINT);
}
}
});
map.addControl(attribution);
map.addControl(attribution);
// add some interactions
map.addInteraction(new KeyboardPan());
map.addInteraction(new KeyboardZoom());
}
// add some interactions
map.addInteraction(new KeyboardPan());
map.addInteraction(new KeyboardZoom());
}
/**
* Sets the center.
*
* @param centerCoordinate the new center
*/
public void setCenter(Coordinate centerCoordinate) {
view.setCenter(centerCoordinate);
view.setCenter(centerCoordinate);
}
/**
* Sets the center.
*
* @param zoom the new zoom
*/
public void setZoom(int zoom) {
view.setZoom(zoom);
view.setZoom(zoom);
}
/**
* Adds the WMS layer.
*
* @param mapServerHost the map server host
* @param layerName the layer name
* @param bbox
* @param layerName the layer name
* @param bbox
* @return the image
*/
public Image addWMSLayer(String mapServerHost, String layerName, BoundsMap bbox) {
GWT.log("Adding wmsLayer with mapServerHost: "+mapServerHost+", layerName: "+layerName);
GWT.log("Adding wmsLayer with mapServerHost: " + mapServerHost + ", layerName: " + layerName);
ImageWmsParams imageWMSParams = OLFactory.createOptions();
imageWMSParams.setLayers(layerName);
//imageWMSParams.setSize(new Size(400,400));
//imageWMSParams.setVersion("1.1.0");
// imageWMSParams.setSize(new Size(400,400));
// imageWMSParams.setVersion("1.1.0");
// if(bbox!=null)
// imageWMSParams.set("BBOX", bbox.getLowerLeftX()+","+bbox.getLowerLeftY()+","+bbox.getUpperRightX()+","+bbox.getUpperRightY());
ImageWmsOptions imageWMSOptions = OLFactory.createOptions();
imageWMSOptions.setUrl(mapServerHost);
imageWMSOptions.setParams(imageWMSParams);
//imageWMSOptions.setRatio(1.5f);
// imageWMSOptions.setRatio(1.5f);
ImageWms imageWMSSource = new ImageWms(imageWMSOptions);
@ -198,50 +196,48 @@ import ol.style.TextOptions;
layerOptions.setSource(imageWMSSource);
ol.layer.Image wmsLayer = new ol.layer.Image(layerOptions);
//visibleLayerItems
// visibleLayerItems
map.addLayer(wmsLayer);
return wmsLayer;
}
/**
* Gets the first layer.
*
* @return the first layer
*/
public Image getFirstLayer() {
if(map.getLayers()!=null) {
if (map.getLayers() != null) {
return (Image) map.getLayers().getArray()[0];
}
return null;
}
/**
* Adds the point.
*
* @param coordinate the coordinate
* @param coordinate the coordinate
* @param showCoordinateText the show coordinate text
* @param asMarker the as marker
* @param asMarker the as marker
*/
public void addPoint(Coordinate coordinate, boolean showCoordinateText, boolean asMarker) {
if(geometryLayer!=null) {
if (geometryLayer != null) {
map.removeLayer(geometryLayer);
}else {
} else {
}
Style style = new Style();
if(asMarker) {
if (asMarker) {
IconOptions iconOptions = new IconOptions();
iconOptions.setSrc(markerURL);
Icon icon = new Icon(iconOptions);
style.setImage(icon);
}
if(showCoordinateText) {
if (showCoordinateText) {
TextOptions textOptions = new TextOptions();
textOptions.setOffsetY(-25);
// StrokeOptions strokeOptions = new StrokeOptions();
@ -253,10 +249,11 @@ import ol.style.TextOptions;
// fillOptions.setColor(new Color(0, 0, 0, 0.0));
// textOptions.setFill(new Fill(fillOptions));
Coordinate transfCoord = MapUtils.transformCoordiante(coordinate, GeoportalDataViewerConstants.EPSG_3857, GeoportalDataViewerConstants.EPSG_4326);
//DecimalFormat df = new DecimalFormat("#.####");
Coordinate transfCoord = MapUtils.transformCoordiante(coordinate, MAP_PROJECTION.EPSG_3857.getName(),
MAP_PROJECTION.EPSG_4326.getName());
// DecimalFormat df = new DecimalFormat("#.####");
NumberFormat fmt = NumberFormat.getFormat("#.####");
textOptions.setText("Long: "+fmt.format(transfCoord.getX()) + ", Lat: "+fmt.format(transfCoord.getY()));
textOptions.setText("Long: " + fmt.format(transfCoord.getX()) + ", Lat: " + fmt.format(transfCoord.getY()));
Text text = new Text(textOptions);
// FillOptions fillOptions = new FillOptions();
@ -266,7 +263,6 @@ import ol.style.TextOptions;
// style.setFill(fill);
style.setText(text);
}
Point thePoint = new Point(coordinate);
Feature vf = new Feature(thePoint);
@ -278,7 +274,7 @@ import ol.style.TextOptions;
geometryLayer = new ol.layer.Vector(vectorLayerOptions);
map.addLayer(geometryLayer);
}
/**
* Gets the map.
*
@ -297,7 +293,6 @@ import ol.style.TextOptions;
return map.getView().getProjection().getCode();
}
/**
* Gets the current zoom level.
*
@ -306,9 +301,7 @@ import ol.style.TextOptions;
public double getCurrentZoomLevel() {
return map.getView().getZoom();
}
/**
* Gets the bbox.
*
@ -317,7 +310,7 @@ import ol.style.TextOptions;
public ol.Extent getBBOX() {
return getExtent();
}
/**
* Gets the extent.
*
@ -326,6 +319,5 @@ import ol.style.TextOptions;
public ol.Extent getExtent() {
return this.map.getView().calculateExtent(map.getSize());
}
}
}

View File

@ -2,7 +2,7 @@ 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.MAP_PROJECTION;
import org.gcube.portlets.user.geoportaldataviewer.client.events.AddedLayerToMapEvent;
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
@ -51,7 +51,7 @@ import ol.source.Osm;
import ol.source.Vector;
import ol.source.XyzOptions;
// TODO: Auto-generated Javadoc
/**
* The Class OpenLayerOSM.
*
@ -147,7 +147,7 @@ public abstract class OpenLayerOSM {
Tile osmLayer = new Tile(osmLayerOptions);
// create a projection
projectionOptions.setCode(GeoportalDataViewerConstants.EPSG_3857);
projectionOptions.setCode(MAP_PROJECTION.EPSG_3857.getName());
projectionOptions.setUnits("m");
Projection projection = new Projection(projectionOptions);
@ -392,6 +392,8 @@ public abstract class OpenLayerOSM {
if (wmsDetailsLayerMap == null)
return;
GWT.log("Removing layers: " + wmsDetailsLayerMap.keySet() + " from map");
for (String key : wmsDetailsLayerMap.keySet()) {
Image layer = wmsDetailsLayerMap.get(key);
map.removeLayer(layer);

View File

@ -16,4 +16,7 @@ public interface Images extends ClientBundle {
@Source("icon_share.png")
ImageResource shareIcon();
@Source("italy.png")
ImageResource italyIcon();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -3,7 +3,9 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui;
import org.gcube.application.geoportalcommon.shared.GeoNaItemRef;
import org.gcube.application.geoportalcommon.shared.products.ConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.model.RecordDV;
import org.gcube.portlets.user.geoportaldataviewer.client.events.MapExtentToEvent;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.NavLink;
@ -23,7 +25,7 @@ import com.google.gwt.user.client.ui.Widget;
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 19, 2020
* Nov 19, 2020
*/
public class GeonaDataViewMainPanel extends Composite {
@ -34,14 +36,14 @@ public class GeonaDataViewMainPanel extends Composite {
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Nov 19, 2020
* Nov 19, 2020
*/
interface GeonaDataViewMainPanelUiBinder extends UiBinder<Widget, GeonaDataViewMainPanel> {
}
@UiField
HTMLPanel mainContainerPanel;
@UiField
HTMLPanel mainToolBar;
@ -50,37 +52,39 @@ public class GeonaDataViewMainPanel extends Composite {
@UiField
NavLink dataBoxSelection;
@UiField
Button removeQuery;
@UiField
DetailsPanel detailsPanel;
@UiField
Button extentToItaly;
private MapPanel mapPanel;
private OpenLayerOSM map;
private HandlerManager applicationBus;
/**
* Instantiates a new geona data view main panel.
*
* @param applicationBus the application bus
* @param mapHeight the map height
* @param mapHeight the map height
*/
public GeonaDataViewMainPanel(HandlerManager applicationBus, int mapHeight) {
initWidget(uiBinder.createAndBindUi(this));
this.applicationBus = applicationBus;
mapPanel = new MapPanel(mapHeight+"px");
detailsPanel.setHeight(mapHeight+"px");
mapPanel = new MapPanel(mapHeight + "px");
detailsPanel.setHeight(mapHeight + "px");
detailsPanel.setApplicationBus(applicationBus);
mainContainerPanel.add(mapPanel);
bindHandlers();
dataPointSelection.setIcon(IconType.SCREENSHOT);
dataBoxSelection.setIcon(IconType.BOOKMARK);
removeQuery.setIcon(IconType.REMOVE);
}
@ -143,9 +147,9 @@ public class GeonaDataViewMainPanel extends Composite {
removeQuery.setVisible(true);
}
});
removeQuery.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
map.removeQueryInteractions();
@ -153,27 +157,36 @@ public class GeonaDataViewMainPanel extends Composite {
}
});
extentToItaly.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
applicationBus.fireEvent(new MapExtentToEvent(ExtentMapUtil.getLocation(ExtentMapUtil.PLACE.ITALY)));
}
});
}
/**
* Show as details.
*
* @param concessioneDV the concessione DV
* @param geonaItemRef the geona item ref
* @param geonaItemRef the geona item ref
*/
public void showAsDetails(ConcessioneDV concessioneDV, GeoNaItemRef geonaItemRef) {
detailsPanel.showDetailsFor(concessioneDV, geonaItemRef);
}
/**
* Hide panel details.
*/
public void hidePanelDetails() {
detailsPanel.hidePanelDetails();
}
/**
* Gets the displyed record.
*

View File

@ -7,6 +7,7 @@
.margin-right-10 {
margin-right: 10px;
}
.font-weight-bold {
font-weight: bold;
}
@ -19,9 +20,17 @@
<g:HTMLPanel ui:field="panelMI"
addStyleNames="info-interaction">
<g:Label>Map Interactions</g:Label>
<b:Paragraph><b:Icon type="CHECK_EMPTY"/> Use <code>Shift+Drag</code> to draw an extent for zoom in the Map</b:Paragraph>
<b:Paragraph><b:Icon type="HAND_UP"/> Click on the Points shown on the Map to view their features</b:Paragraph>
</g:HTMLPanel>
<b:Paragraph>
<b:Icon type="CHECK_EMPTY" />
Use
<code>Shift+Drag</code>
to draw an extent for zoom in the Map
</b:Paragraph>
<b:Paragraph>
<b:Icon type="HAND_UP" />
Click on the Points shown on the Map to view their features
</b:Paragraph>
</g:HTMLPanel>
</b:DropdownButton>
<b:DropdownButton type="LINK" text="Query"
visible="false">
@ -33,6 +42,8 @@
Selection</b:NavLink>
<!-- </b:ButtonGroup> -->
</b:DropdownButton>
<b:Button type="LINK" ui:field="extentToItaly"
text="Extent"></b:Button>
<b:Button type="LINK" ui:field="removeQuery"
text="Remove Query" visible="false"></b:Button>
</g:HTMLPanel>

View File

@ -0,0 +1,170 @@
package org.gcube.portlets.user.geoportaldataviewer.client.ui.map;
import java.util.HashMap;
import java.util.Map;
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.gis.MapUtils;
import ol.Coordinate;
import ol.OLFactory;
/**
* The Class ExtentMapUtil.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Sep 1, 2021
*/
public class ExtentMapUtil {
/**
* The Enum PLACE.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Sep 1, 2021
*/
public static enum PLACE {
ITALY
}
final static Map<PLACE, Location> mapExtent = new HashMap<PLACE, Location>();
static {
// EPSG_4326 ITALY LOCATION
Location location = new Location(PLACE.ITALY.name(), GeoportalDataViewerConstants.ITALY_CENTER_LONG,
GeoportalDataViewerConstants.ITALY_CENTER_LAT, MAP_PROJECTION.EPSG_4326,
GeoportalDataViewerConstants.MAP_ITALY_FIT_ZOOM_ON);
mapExtent.put(PLACE.ITALY, location);
}
public static Location getLocation(PLACE place) {
return mapExtent.get(place);
}
/**
* The Class Location.
*
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
*
* Sep 1, 2021
*/
public static class Location {
public String name;
public double coordinateX;
public double coordinateY;
public MAP_PROJECTION projection;
public int zoomLevel;
/**
* Instantiates a new location.
*
* @param name the name
* @param coordinateX the coordinate X
* @param coordinateY the coordinate Y
* @param projection the projection
* @param zoomLevel the zoom level
*/
public Location(String name, double coordinateX, double coordinateY, MAP_PROJECTION projection, int zoomLevel) {
super();
this.name = name;
this.coordinateX = coordinateX;
this.coordinateY = coordinateY;
this.projection = projection;
this.zoomLevel = zoomLevel;
}
/**
* Gets the name.
*
* @return the name
*/
public String getName() {
return name;
}
/**
* Gets the coordinate X.
*
* @return the coordinate X
*/
public double getCoordinateX() {
return coordinateX;
}
/**
* Gets the coordinate Y.
*
* @return the coordinate Y
*/
public double getCoordinateY() {
return coordinateY;
}
/**
* Gets the projection.
*
* @return the projection
*/
public MAP_PROJECTION getProjection() {
return projection;
}
/**
* Gets the zoom level.
*
* @return the zoom level
*/
public int getZoomLevel() {
return zoomLevel;
}
/**
* Gets the coordinate.
*
* @param targetProjection the target projection
* @return the coordinate
*/
public Coordinate getCoordinate(MAP_PROJECTION targetProjection) {
Coordinate coordinate = OLFactory.createCoordinate(coordinateX, coordinateY);
if (projection.equals(targetProjection)) {
return coordinate;
} else {
Coordinate transformedCenterCoordinate = MapUtils.transformCoordiante(coordinate, projection.getName(),
targetProjection.getName());
return transformedCenterCoordinate;
}
}
/**
* To string.
*
* @return the string
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("Location [name=");
builder.append(name);
builder.append(", coordinateX=");
builder.append(coordinateX);
builder.append(", coordinateY=");
builder.append(coordinateY);
builder.append(", projection=");
builder.append(projection);
builder.append(", zoomLevel=");
builder.append(zoomLevel);
builder.append("]");
return builder.toString();
}
}
}

View File

@ -2,9 +2,12 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui.map;
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.gis.ExtentWrapped;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.LightOpenLayerOSM;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.Location;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.PLACE;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
@ -67,12 +70,18 @@ import ol.OLFactory;
@Override
public void execute() {
olsm = new LightOpenLayerOSM(theMapId);
//EPSG_4326_TO_ITALY
Coordinate centerCoordinate = OLFactory.createCoordinate(GeoportalDataViewerConstants.ITALY_CENTER_LONG, GeoportalDataViewerConstants.ITALY_CENTER_LAT);
Coordinate transformedCenterCoordinate = MapUtils.transformCoordiante(centerCoordinate, GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857);
//EPSG_3857 LOCATION TO ITALY
Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY);
Coordinate transformedCenterCoordinate = italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857);
olsm.setCenter(transformedCenterCoordinate);
olsm.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();
}
@ -136,14 +145,13 @@ import ol.OLFactory;
if (bbox != null) {
Coordinate lower = OLFactory.createCoordinate(bbox.getLowerLeftX(), bbox.getLowerLeftY());
Coordinate lowerCoord = MapUtils.transformCoordiante(lower, GeoportalDataViewerConstants.EPSG_4326,
GeoportalDataViewerConstants.EPSG_3857);
Coordinate lowerCoord = MapUtils.transformCoordiante(lower, MAP_PROJECTION.EPSG_4326.getName(),
MAP_PROJECTION.EPSG_3857.getName());
Coordinate upper = OLFactory.createCoordinate(bbox.getUpperRightX(), bbox.getUpperRightY());
Coordinate upperCoord = MapUtils.transformCoordiante(upper, GeoportalDataViewerConstants.EPSG_4326,
GeoportalDataViewerConstants.EPSG_3857);
Coordinate upperCoord = MapUtils.transformCoordiante(upper, MAP_PROJECTION.EPSG_4326.getName(),
MAP_PROJECTION.EPSG_3857.getName());
ew = new ExtentWrapped(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(), upperCoord.getY());
theBBOX = new BoundsMap(lowerCoord.getX(), lowerCoord.getY(), upperCoord.getX(), upperCoord.getY(), null);

View File

@ -9,11 +9,15 @@ import org.gcube.application.geoportalcommon.shared.products.model.AbstractRelaz
import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV;
import org.gcube.application.geoportalcommon.shared.products.model.UploadedImageDV;
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.GeoportalDataViewerServiceAsync;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.ModalWindow;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.dialogs.DialogShareableLink;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.gallery.ImagesGallery;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.Location;
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.util.CustomFlexTable;
@ -35,7 +39,6 @@ import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Widget;
import ol.Coordinate;
import ol.OLFactory;
public class ConcessioneView extends Composite {
@ -300,13 +303,15 @@ public class ConcessioneView extends Composite {
}
private void addCentroidMap() {
Coordinate centerCoordinate = OLFactory.createCoordinate(GeoportalDataViewerConstants.ITALY_CENTER_LONG, GeoportalDataViewerConstants.ITALY_CENTER_LAT);
Coordinate transformedCenterCoordinate = MapUtils.transformCoordiante(centerCoordinate, GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857);
// Coordinate centerCoordinate = OLFactory.createCoordinate(GeoportalDataViewerConstants.ITALY_CENTER_LONG, GeoportalDataViewerConstants.ITALY_CENTER_LAT);
// Coordinate transformedCenterCoordinate = MapUtils.transformCoordiante(centerCoordinate, GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857);
Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY);
Coordinate transformedCenterCoordinate = italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857);
MapView mapView = new MapView(transformedCenterCoordinate, GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON, "70%", "300px");
if(concessioneDV!=null && concessioneDV.getCentroidLat()!=null && concessioneDV.getCentroidLong()!=null) {
Coordinate coord = new Coordinate(concessioneDV.getCentroidLong(), concessioneDV.getCentroidLat());
Coordinate transfCoord = MapUtils.transformCoordiante(coord, GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857);
Coordinate transfCoord = MapUtils.transformCoordiante(coord, MAP_PROJECTION.EPSG_4326.getName(), MAP_PROJECTION.EPSG_3857.getName());
//Coordinate invertedCoordinate = MapUtils.reverseCoordinate(coord);
boolean authenticatedUser = myLogin!=null?true:false;
mapView.addMarker(transfCoord, authenticatedUser);

View File

@ -2,7 +2,10 @@ package org.gcube.portlets.user.geoportaldataviewer.client.ui.products.concessio
import org.gcube.application.geoportalcommon.shared.products.model.LayerConcessioneDV;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
import org.gcube.portlets.user.geoportaldataviewer.client.gis.MapUtils;
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.MAP_PROJECTION;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil;
import org.gcube.portlets.user.geoportaldataviewer.client.ui.map.ExtentMapUtil.Location;
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.util.CustomFlexTable;
@ -14,7 +17,6 @@ import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Widget;
import ol.Coordinate;
import ol.OLFactory;
public class LayerConcessioneView extends Composite {
@ -44,8 +46,12 @@ public class LayerConcessioneView extends Composite {
GWT.log("WMS LINK: "+layerDV.getWmsLink());
if(layerDV.getLayerName()!=null && layerDV.getWmsLink()!=null) {
Coordinate centerCoordinate = OLFactory.createCoordinate(GeoportalDataViewerConstants.ITALY_CENTER_LONG, GeoportalDataViewerConstants.ITALY_CENTER_LAT);
Coordinate transformedCenterCoordinate = MapUtils.transformCoordiante(centerCoordinate, GeoportalDataViewerConstants.EPSG_4326, GeoportalDataViewerConstants.EPSG_3857);
Location italyLocation = ExtentMapUtil.getLocation(PLACE.ITALY);
Coordinate transformedCenterCoordinate = italyLocation.getCoordinate(MAP_PROJECTION.EPSG_3857);
// 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());
MapView mapView = new MapView(transformedCenterCoordinate, GeoportalDataViewerConstants.LIGHT_MAP_ITALY_FIT_ZOOM_ON, "70%", "300px");
mapViewPanel.add(mapView);