|
|
|
@ -1,5 +1,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.events.AddedLayerToMapEvent;
|
|
|
|
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
|
|
|
|
@ -13,6 +15,8 @@ import com.google.gwt.user.client.Event;
|
|
|
|
|
|
|
|
|
|
import ol.Collection;
|
|
|
|
|
import ol.Coordinate;
|
|
|
|
|
import ol.Feature;
|
|
|
|
|
import ol.FeatureOptions;
|
|
|
|
|
import ol.Map;
|
|
|
|
|
import ol.MapBrowserEvent;
|
|
|
|
|
import ol.MapEvent;
|
|
|
|
@ -25,6 +29,7 @@ import ol.View;
|
|
|
|
|
import ol.ViewOptions;
|
|
|
|
|
import ol.control.Attribution;
|
|
|
|
|
import ol.event.EventListener;
|
|
|
|
|
import ol.geom.Geometry;
|
|
|
|
|
import ol.interaction.Draw;
|
|
|
|
|
import ol.interaction.DrawOptions;
|
|
|
|
|
import ol.interaction.Extent;
|
|
|
|
@ -36,6 +41,7 @@ import ol.layer.Base;
|
|
|
|
|
import ol.layer.Image;
|
|
|
|
|
import ol.layer.LayerOptions;
|
|
|
|
|
import ol.layer.Tile;
|
|
|
|
|
import ol.layer.VectorLayerOptions;
|
|
|
|
|
import ol.proj.Projection;
|
|
|
|
|
import ol.proj.ProjectionOptions;
|
|
|
|
|
import ol.source.ImageWms;
|
|
|
|
@ -45,74 +51,101 @@ import ol.source.Osm;
|
|
|
|
|
import ol.source.Vector;
|
|
|
|
|
import ol.source.XyzOptions;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Auto-generated Javadoc
|
|
|
|
|
/**
|
|
|
|
|
* The Class OpenLayerOSM.
|
|
|
|
|
*
|
|
|
|
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
|
|
|
|
*
|
|
|
|
|
* Oct 27, 2020
|
|
|
|
|
* Oct 27, 2020
|
|
|
|
|
*/
|
|
|
|
|
public abstract class OpenLayerOSM {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Click listener.
|
|
|
|
|
*
|
|
|
|
|
* @param event the event
|
|
|
|
|
*/
|
|
|
|
|
public abstract void clickListener(MapBrowserEvent event);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Move end listener.
|
|
|
|
|
*
|
|
|
|
|
* @param event the event
|
|
|
|
|
*/
|
|
|
|
|
public abstract void moveEndListener(MapEvent event);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Move start listener.
|
|
|
|
|
*
|
|
|
|
|
* @param event the event
|
|
|
|
|
*/
|
|
|
|
|
public abstract void moveStartListener(MapEvent event);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Map zoom listener.
|
|
|
|
|
*
|
|
|
|
|
* @param event the event
|
|
|
|
|
*/
|
|
|
|
|
public abstract void mapZoomListener(MapEvent event);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Map zoom end listener.
|
|
|
|
|
*
|
|
|
|
|
* @param event the event
|
|
|
|
|
*/
|
|
|
|
|
public abstract void mapZoomEndListener(MapEvent event);
|
|
|
|
|
|
|
|
|
|
/** 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();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** The point draw. */
|
|
|
|
|
private Draw queryPoint;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Extent queryBox;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** The popup overlay. */
|
|
|
|
|
private Overlay popupOverlay;
|
|
|
|
|
|
|
|
|
|
private HandlerManager eventBus;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean isQueryBoxActive;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean isQueryPointActive;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Instantiates a new open layer OSM.
|
|
|
|
|
*
|
|
|
|
|
* @param divTargetId the div target id
|
|
|
|
|
* @param eventBus the event bus
|
|
|
|
|
*/
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
|
* @see de.desjardins.ol3.demo.client.example.Example#show()
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
private java.util.Map<String, Image> wmsDetailsLayerMap;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Instantiates a new open layer OSM.
|
|
|
|
|
*
|
|
|
|
|
* @param divTargetId the div target id
|
|
|
|
|
* @param eventBus the event bus
|
|
|
|
|
*/
|
|
|
|
|
/*
|
|
|
|
|
* (non-Javadoc)
|
|
|
|
|
*
|
|
|
|
|
* @see de.desjardins.ol3.demo.client.example.Example#show()
|
|
|
|
|
*/
|
|
|
|
|
public OpenLayerOSM(String divTargetId, HandlerManager eventBus) {
|
|
|
|
|
this.eventBus = eventBus;
|
|
|
|
|
|
|
|
|
|
// 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.setUnits("m");
|
|
|
|
@ -120,39 +153,41 @@ public abstract class OpenLayerOSM {
|
|
|
|
|
Projection projection = new Projection(projectionOptions);
|
|
|
|
|
viewOptions.setProjection(projection);
|
|
|
|
|
viewOptions.setMaxZoom(19);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// create a view
|
|
|
|
|
view = new View(viewOptions);
|
|
|
|
|
|
|
|
|
|
// create the map
|
|
|
|
|
MapOptions mapOptions = OLFactory.createOptions();
|
|
|
|
|
mapOptions.setTarget(divTargetId);
|
|
|
|
|
mapOptions.setView(view);
|
|
|
|
|
|
|
|
|
|
map = new Map(mapOptions);
|
|
|
|
|
|
|
|
|
|
map.addLayer(osmLayer);
|
|
|
|
|
//map.addLayer(tileDebugLayer);
|
|
|
|
|
|
|
|
|
|
// add some controls
|
|
|
|
|
map.addControl(OLFactory.createScaleLine());
|
|
|
|
|
MapUtils.addDefaultControls(map.getControls());
|
|
|
|
|
|
|
|
|
|
Attribution attribution = new Attribution();
|
|
|
|
|
attribution.setCollapsed(true);
|
|
|
|
|
map.addControl(attribution);
|
|
|
|
|
|
|
|
|
|
// add some interactions
|
|
|
|
|
map.addInteraction(new KeyboardPan());
|
|
|
|
|
map.addInteraction(new KeyboardZoom());
|
|
|
|
|
|
|
|
|
|
bindEvents();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// create a view
|
|
|
|
|
view = new View(viewOptions);
|
|
|
|
|
|
|
|
|
|
// create the map
|
|
|
|
|
MapOptions mapOptions = OLFactory.createOptions();
|
|
|
|
|
mapOptions.setTarget(divTargetId);
|
|
|
|
|
mapOptions.setView(view);
|
|
|
|
|
|
|
|
|
|
map = new Map(mapOptions);
|
|
|
|
|
|
|
|
|
|
map.addLayer(osmLayer);
|
|
|
|
|
// map.addLayer(tileDebugLayer);
|
|
|
|
|
|
|
|
|
|
// add some controls
|
|
|
|
|
map.addControl(OLFactory.createScaleLine());
|
|
|
|
|
MapUtils.addDefaultControls(map.getControls());
|
|
|
|
|
|
|
|
|
|
Attribution attribution = new Attribution();
|
|
|
|
|
attribution.setCollapsed(true);
|
|
|
|
|
map.addControl(attribution);
|
|
|
|
|
|
|
|
|
|
// add some interactions
|
|
|
|
|
map.addInteraction(new KeyboardPan());
|
|
|
|
|
map.addInteraction(new KeyboardZoom());
|
|
|
|
|
|
|
|
|
|
bindEvents();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Bind events.
|
|
|
|
|
*/
|
|
|
|
|
private void bindEvents() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
map.addClickListener(new EventListener<MapBrowserEvent>() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -168,7 +203,7 @@ public abstract class OpenLayerOSM {
|
|
|
|
|
moveEndListener(event);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
map.addMoveStartListener(new EventListener<MapEvent>() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -176,7 +211,7 @@ public abstract class OpenLayerOSM {
|
|
|
|
|
moveStartListener(event);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
map.addMapZoomListener(new EventListener<MapEvent>() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -184,7 +219,7 @@ public abstract class OpenLayerOSM {
|
|
|
|
|
mapZoomListener(event);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
map.addMapZoomEndListener(new EventListener<MapEvent>() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -193,32 +228,37 @@ public abstract class OpenLayerOSM {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the center.
|
|
|
|
|
*
|
|
|
|
|
* @param centerCoordinate the new center
|
|
|
|
|
*/
|
|
|
|
|
public void setCenter(Coordinate centerCoordinate) {
|
|
|
|
|
view.setCenter(centerCoordinate);
|
|
|
|
|
view.setCenter(centerCoordinate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets the center.
|
|
|
|
|
*
|
|
|
|
|
* @param centerCoordinate the new center
|
|
|
|
|
* @param zoom the new zoom
|
|
|
|
|
*/
|
|
|
|
|
public void setZoom(int zoom) {
|
|
|
|
|
view.setZoom(zoom);
|
|
|
|
|
view.setZoom(zoom);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Show popup.
|
|
|
|
|
*
|
|
|
|
|
* @param html the html
|
|
|
|
|
* @param coordinate the coordinate
|
|
|
|
|
*/
|
|
|
|
|
public void showPopup(String html, Coordinate coordinate) {
|
|
|
|
|
GWT.log("Showing popup on: "+coordinate);
|
|
|
|
|
//GeoportalDataViewerConstants.print("Showing popup on: "+coordinate);
|
|
|
|
|
GWT.log("Showing popup on: " + coordinate);
|
|
|
|
|
// GeoportalDataViewerConstants.print("Showing popup on: "+coordinate);
|
|
|
|
|
Element elPopup = DOM.getElementById("popup");
|
|
|
|
|
elPopup.getStyle().setVisibility(Visibility.VISIBLE);
|
|
|
|
|
if(popupOverlay==null) {
|
|
|
|
|
if (popupOverlay == null) {
|
|
|
|
|
popupOverlay = addOverlay(elPopup);
|
|
|
|
|
addPopupCloserHandelr(popupOverlay);
|
|
|
|
|
}
|
|
|
|
@ -226,14 +266,17 @@ public abstract class OpenLayerOSM {
|
|
|
|
|
popContent.setInnerHTML(html);
|
|
|
|
|
popupOverlay.setPosition(coordinate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Hide popup.
|
|
|
|
|
*/
|
|
|
|
|
public void hidePopup() {
|
|
|
|
|
if(popupOverlay!=null) {
|
|
|
|
|
if (popupOverlay != null) {
|
|
|
|
|
Element elPopup = DOM.getElementById("popup");
|
|
|
|
|
elPopup.getStyle().setVisibility(Visibility.HIDDEN);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds the popup closer handelr.
|
|
|
|
|
*
|
|
|
|
@ -253,11 +296,11 @@ public abstract class OpenLayerOSM {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Handler popu closer.
|
|
|
|
|
*
|
|
|
|
|
* @param divId the div id
|
|
|
|
|
* @param divId the div id
|
|
|
|
|
* @param overlayId the overlay id
|
|
|
|
|
*/
|
|
|
|
|
public static native void handlerPopuCloser(String divId, String overlayId) /*-{
|
|
|
|
@ -271,21 +314,20 @@ public abstract class OpenLayerOSM {
|
|
|
|
|
|
|
|
|
|
}-*/;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds the WMS layer.
|
|
|
|
|
*
|
|
|
|
|
* @param layerItem the layer item
|
|
|
|
|
*/
|
|
|
|
|
public void addWMSLayer(LayerItem layerItem) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ImageWmsParams imageWMSParams = OLFactory.createOptions();
|
|
|
|
|
imageWMSParams.setLayers(layerItem.getName());
|
|
|
|
|
|
|
|
|
|
ImageWmsOptions imageWMSOptions = OLFactory.createOptions();
|
|
|
|
|
imageWMSOptions.setUrl(layerItem.getMapServerHost());
|
|
|
|
|
imageWMSOptions.setParams(imageWMSParams);
|
|
|
|
|
//imageWMSOptions.setRatio(1.5f);
|
|
|
|
|
// imageWMSOptions.setRatio(1.5f);
|
|
|
|
|
|
|
|
|
|
ImageWms imageWMSSource = new ImageWms(imageWMSOptions);
|
|
|
|
|
|
|
|
|
@ -293,29 +335,142 @@ public abstract class OpenLayerOSM {
|
|
|
|
|
layerOptions.setSource(imageWMSSource);
|
|
|
|
|
|
|
|
|
|
Image wmsLayer = new Image(layerOptions);
|
|
|
|
|
|
|
|
|
|
//visibleLayerItems
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// visibleLayerItems
|
|
|
|
|
|
|
|
|
|
map.addLayer(wmsLayer);
|
|
|
|
|
GWT.log("Fired the event Added Layer");
|
|
|
|
|
eventBus.fireEvent(new AddedLayerToMapEvent(layerItem));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds the WMS detail layer.
|
|
|
|
|
*
|
|
|
|
|
* @param layerItem the layer item
|
|
|
|
|
*/
|
|
|
|
|
public void addWMSDetailLayer(LayerItem layerItem) {
|
|
|
|
|
|
|
|
|
|
if (wmsDetailsLayerMap == null)
|
|
|
|
|
wmsDetailsLayerMap = new HashMap<String, Image>();
|
|
|
|
|
|
|
|
|
|
String key = layerItem.getMapServerHost() + "/layer/" + layerItem.getName();
|
|
|
|
|
|
|
|
|
|
Image layer = wmsDetailsLayerMap.get(key);
|
|
|
|
|
|
|
|
|
|
if (layer == null) {
|
|
|
|
|
GWT.log("The detail layer with key: " + key + " does not exist, creating and adding it to map");
|
|
|
|
|
ImageWmsParams imageWMSParams = OLFactory.createOptions();
|
|
|
|
|
imageWMSParams.setLayers(layerItem.getName());
|
|
|
|
|
|
|
|
|
|
ImageWmsOptions imageWMSOptions = OLFactory.createOptions();
|
|
|
|
|
imageWMSOptions.setUrl(layerItem.getMapServerHost());
|
|
|
|
|
imageWMSOptions.setParams(imageWMSParams);
|
|
|
|
|
// imageWMSOptions.setRatio(1.5f);
|
|
|
|
|
|
|
|
|
|
ImageWms imageWMSSource = new ImageWms(imageWMSOptions);
|
|
|
|
|
|
|
|
|
|
LayerOptions layerOptions = OLFactory.createOptions();
|
|
|
|
|
layerOptions.setSource(imageWMSSource);
|
|
|
|
|
|
|
|
|
|
Image wmsLayer = new Image(layerOptions);
|
|
|
|
|
|
|
|
|
|
// visibleLayerItems
|
|
|
|
|
|
|
|
|
|
map.addLayer(wmsLayer);
|
|
|
|
|
wmsDetailsLayerMap.put(key, wmsLayer);
|
|
|
|
|
|
|
|
|
|
GWT.log("Fired the event Added Layer");
|
|
|
|
|
eventBus.fireEvent(new AddedLayerToMapEvent(layerItem));
|
|
|
|
|
} else {
|
|
|
|
|
GWT.log("The detail layer with key: " + key + " already exists, skipping");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void removeAllDetailLayers() {
|
|
|
|
|
if (wmsDetailsLayerMap == null)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
for (String key : wmsDetailsLayerMap.keySet()) {
|
|
|
|
|
Image layer = wmsDetailsLayerMap.get(key);
|
|
|
|
|
map.removeLayer(layer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wmsDetailsLayerMap.clear();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
|
*
|
|
|
|
|
* @param geometry the geometry
|
|
|
|
|
*/
|
|
|
|
|
public void addVector(Geometry geometry) {
|
|
|
|
|
|
|
|
|
|
VectorLayerOptions vectorLayerOptions = new VectorLayerOptions();
|
|
|
|
|
vectorLayerOptions.setMap(map);
|
|
|
|
|
|
|
|
|
|
// Style style = new Style();
|
|
|
|
|
// FillOptions fillOptions = new FillOptions();
|
|
|
|
|
// Color color = new Color(0, 0, 255, 1.0);
|
|
|
|
|
// fillOptions.setColor(color);
|
|
|
|
|
// Fill fill = new Fill(fillOptions);
|
|
|
|
|
// style.setFill(fill);
|
|
|
|
|
|
|
|
|
|
FeatureOptions featureOptions = new FeatureOptions();
|
|
|
|
|
featureOptions.setGeometry(geometry);
|
|
|
|
|
Feature feature = OLFactory.createFeature(featureOptions);
|
|
|
|
|
|
|
|
|
|
Vector vectorSource = OLFactory.createVectorSource();
|
|
|
|
|
vectorSource.addFeature(feature);
|
|
|
|
|
vectorLayerOptions.setSource(vectorSource);
|
|
|
|
|
|
|
|
|
|
ol.layer.Vector vector = OLFactory.createVector(vectorLayerOptions);
|
|
|
|
|
|
|
|
|
|
map.addLayer(vector);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds the point vector source.
|
|
|
|
|
*
|
|
|
|
|
* @return the draw
|
|
|
|
|
*/
|
|
|
|
|
public Draw addPointVectorSource() {
|
|
|
|
|
if(queryPoint==null)
|
|
|
|
|
if (queryPoint == null)
|
|
|
|
|
initPointInteraction();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
map.addInteraction(queryPoint);
|
|
|
|
|
isQueryPointActive = true;
|
|
|
|
|
return queryPoint;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Inits the point interaction.
|
|
|
|
|
*/
|
|
|
|
@ -328,39 +483,39 @@ public abstract class OpenLayerOSM {
|
|
|
|
|
drawOptions.setMinPoints(1);
|
|
|
|
|
drawOptions.setWrapX(false);
|
|
|
|
|
queryPoint = new Draw(drawOptions);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
queryPoint.addChangeListener(new EventListener<ol.events.Event>() {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onEvent(ol.events.Event event) {
|
|
|
|
|
GWT.log(event.getType());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Removes the interaction.
|
|
|
|
|
*
|
|
|
|
|
* @param interaction the interaction
|
|
|
|
|
*/
|
|
|
|
|
public void removeInteraction(Interaction interaction) {
|
|
|
|
|
map.removeInteraction(interaction);
|
|
|
|
|
map.removeInteraction(interaction);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Removes the interactions.
|
|
|
|
|
*/
|
|
|
|
|
public void removeQueryInteractions() {
|
|
|
|
|
Collection<Interaction> interactions = map.getInteractions();
|
|
|
|
|
if(interactions!=null) {
|
|
|
|
|
if (interactions != null) {
|
|
|
|
|
map.removeInteraction(queryBox);
|
|
|
|
|
map.removeInteraction(queryPoint);
|
|
|
|
|
isQueryBoxActive = false;
|
|
|
|
|
isQueryPointActive = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds the extent interaction.
|
|
|
|
|
*
|
|
|
|
@ -369,17 +524,16 @@ public abstract class OpenLayerOSM {
|
|
|
|
|
public Extent addExtentInteraction() {
|
|
|
|
|
ExtentOptions extentOptions = new ExtentOptions();
|
|
|
|
|
extentOptions.setWrapX(false);
|
|
|
|
|
//StyleOptions styleOptions = new StyleOptions();
|
|
|
|
|
//styleOptions.setStroke(stroke);
|
|
|
|
|
//styleOptions.set
|
|
|
|
|
//extentOptions.setBoxStyle(new ol.style.Style(styleOptions));
|
|
|
|
|
// StyleOptions styleOptions = new StyleOptions();
|
|
|
|
|
// styleOptions.setStroke(stroke);
|
|
|
|
|
// styleOptions.set
|
|
|
|
|
// extentOptions.setBoxStyle(new ol.style.Style(styleOptions));
|
|
|
|
|
queryBox = new Extent(extentOptions);
|
|
|
|
|
map.addInteraction(queryBox);
|
|
|
|
|
isQueryBoxActive = true;
|
|
|
|
|
return queryBox;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Adds the overlay.
|
|
|
|
|
*
|
|
|
|
@ -405,23 +559,22 @@ public abstract class OpenLayerOSM {
|
|
|
|
|
* @return true, if is layer visible
|
|
|
|
|
*/
|
|
|
|
|
public boolean isLayerVisible(String layerName) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Collection<Base> layers = map.getLayers();
|
|
|
|
|
|
|
|
|
|
if(layers!=null) {
|
|
|
|
|
|
|
|
|
|
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))
|
|
|
|
|
GWT.log("The Layer name is: " + layerName);
|
|
|
|
|
if (theLayerName != null && theLayerName.equals(layerName))
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the projection code.
|
|
|
|
@ -431,7 +584,6 @@ public abstract class OpenLayerOSM {
|
|
|
|
|
public String getProjectionCode() {
|
|
|
|
|
return map.getView().getProjection().getCode();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the current zoom level.
|
|
|
|
@ -441,9 +593,7 @@ public abstract class OpenLayerOSM {
|
|
|
|
|
public double getCurrentZoomLevel() {
|
|
|
|
|
return map.getView().getZoom();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the bbox.
|
|
|
|
|
*
|
|
|
|
@ -452,7 +602,7 @@ public abstract class OpenLayerOSM {
|
|
|
|
|
public ol.Extent getBBOX() {
|
|
|
|
|
return getExtent();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the extent.
|
|
|
|
|
*
|
|
|
|
@ -461,26 +611,53 @@ public abstract class OpenLayerOSM {
|
|
|
|
|
public ol.Extent getExtent() {
|
|
|
|
|
return this.map.getView().calculateExtent(map.getSize());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Coordinate transform (Coordinate centerCoordinate, String source, String target){
|
|
|
|
|
return Projection.transform(centerCoordinate, source, target);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Transform.
|
|
|
|
|
*
|
|
|
|
|
* @param centerCoordinate the center coordinate
|
|
|
|
|
* @param source the source
|
|
|
|
|
* @param target the target
|
|
|
|
|
* @return the coordinate
|
|
|
|
|
*/
|
|
|
|
|
public Coordinate transform(Coordinate centerCoordinate, String source, String target) {
|
|
|
|
|
return Projection.transform(centerCoordinate, source, target);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Checks if is query box active.
|
|
|
|
|
*
|
|
|
|
|
* @return true, if is query box active
|
|
|
|
|
*/
|
|
|
|
|
public boolean isQueryBoxActive() {
|
|
|
|
|
return isQueryBoxActive;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Checks if is query point active.
|
|
|
|
|
*
|
|
|
|
|
* @return true, if is query point active
|
|
|
|
|
*/
|
|
|
|
|
public boolean isQueryPointActive() {
|
|
|
|
|
return isQueryPointActive;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Gets the size.
|
|
|
|
|
*
|
|
|
|
|
* @return the size
|
|
|
|
|
*/
|
|
|
|
|
public Size getSize() {
|
|
|
|
|
return map.getSize();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Map instancied.
|
|
|
|
|
*
|
|
|
|
|
* @return true, if successful
|
|
|
|
|
*/
|
|
|
|
|
public boolean mapInstancied() {
|
|
|
|
|
return this.map!=null;
|
|
|
|
|
}
|
|
|
|
|
return this.map != null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|