added MAP_PROJECTION object
parent
b2e6830bbe
commit
b337955f71
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue