added logic to display Popup on Zoom level interaction
This commit is contained in:
parent
db668a37a8
commit
2fb8f459b4
|
@ -4,8 +4,6 @@ import java.util.Iterator;
|
|||
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEvent;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.events.ShowDetailsEventHandler;
|
||||
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.GeonaDataViewMainPanel;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataViewerProfile;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
|
||||
|
@ -23,9 +21,6 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
|
|||
import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.gwt.user.client.ui.RootPanel;
|
||||
|
||||
import ol.Coordinate;
|
||||
import ol.OLFactory;
|
||||
|
||||
// TODO: Auto-generated Javadoc
|
||||
/**
|
||||
* Entry point classes define <code>onModuleLoad()</code>.
|
||||
|
@ -46,7 +41,7 @@ public class GeoportalDataViewer implements EntryPoint {
|
|||
public final static String APP_DIV = "geoportal-data-viewer";
|
||||
|
||||
/** The ol map. */
|
||||
private OpenLayerOSM olMap = null;
|
||||
//private OpenLayerOSM olMap = null;
|
||||
|
||||
/** The main panel. */
|
||||
private GeonaDataViewMainPanel mainPanel;
|
||||
|
@ -71,6 +66,8 @@ public class GeoportalDataViewer implements EntryPoint {
|
|||
|
||||
private GeoNaDataViewerProfile geonaDataViewerProfile;
|
||||
|
||||
private OLMapManager olMapMng = null;
|
||||
|
||||
//https://data.d4science.org/gis-viewer-app/?wmsrequest=https%3A%2F%2Fgeona-proto.d4science.org%2Fgeoserver%2Fconcessioni_conf%2Fwms%3Fservice%3DWMS%26version%3D1.1.0%26request%3DGetMap%26layers%3Dconcessioni_conf%3Acentroids_concessioni%26styles%3D%26bbox%3D8.476%2C39.179%2C17.391%2C45.772%26width%3D768%26height%3D567%26srs%3DEPSG%3A4326%26format%3Dapplication%2Fopenlayers&zoom=6¢ermap=12.45%2C42.98
|
||||
|
||||
/**
|
||||
|
@ -86,17 +83,11 @@ public class GeoportalDataViewer implements EntryPoint {
|
|||
|
||||
@Override
|
||||
public void execute() {
|
||||
olMap = new OpenLayerOSM(mainPanel.getMapPanel().getElement().getId(),layerManager.getEventBus());
|
||||
layerManager.setOlMap(olMap);
|
||||
mainPanel.setMap(olMap);
|
||||
|
||||
olMapMng = new OLMapManager(mainPanel.getMapPanel().getElement().getId(),layerManager.getEventBus());
|
||||
layerManager.setOlMap(olMapMng.getOLOSMMap());
|
||||
mainPanel.setMap(olMapMng.getOLOSMMap());
|
||||
|
||||
//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);
|
||||
|
||||
olMap.setCenter(transformedCenterCoordinate);
|
||||
olMap.setZoom(GeoportalDataViewerConstants.ITALY_FIT_ZOOM_ON);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -176,7 +167,7 @@ public class GeoportalDataViewer implements EntryPoint {
|
|||
|
||||
bindEvents();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Bind events.
|
||||
*/
|
||||
|
|
|
@ -20,7 +20,7 @@ public class GeoportalDataViewerConstants {
|
|||
|
||||
public enum LayerType {RASTER_BASELAYER, FEATURE_TYPE};
|
||||
|
||||
public static final int MAX_WFS_FEATURES = 5; // zero for no limit
|
||||
public static final int MAX_WFS_FEATURES = 3; // zero for no limit
|
||||
|
||||
public static final String NEW_LINE_BR = "<br/>";
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery;
|
|||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerObject;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.PointsPath;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.GeoInformationForWMSRequest;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wms.ZAxis;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.products.content.WorkspaceContentDV;
|
||||
|
@ -239,6 +240,9 @@ public class LayerManager {
|
|||
//break; //Only the first one
|
||||
}
|
||||
|
||||
if(feature==null)
|
||||
return;
|
||||
|
||||
GWT.log("The selected Feature is: "+feature);
|
||||
FeatureRow theFeature = feature;
|
||||
Button button = null;
|
||||
|
@ -266,8 +270,19 @@ public class LayerManager {
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
PointsPath path = feature.getGeometry().getPath();
|
||||
GWT.log("Points Path: "+path);
|
||||
Coordinate centerTo = null;
|
||||
if(path!=null && path.getCoordinates()!=null && path.getCoordinates().length>0) {
|
||||
org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.Coordinate center = path.getCoordinates()[0];
|
||||
centerTo = new Coordinate(center.getX(), center.getY());
|
||||
}
|
||||
|
||||
if(centerTo==null)
|
||||
centerTo = queryEvent.getoLCoordinate();
|
||||
|
||||
olMap.showPopup(vpPanel.toString(), queryEvent.getoLCoordinate());
|
||||
olMap.showPopup(vpPanel.toString(), centerTo);
|
||||
|
||||
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||
|
||||
|
|
|
@ -0,0 +1,199 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.client;
|
||||
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEvent;
|
||||
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.shared.gis.GeoQuery;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery.TYPE;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.shared.HandlerManager;
|
||||
|
||||
import ol.Coordinate;
|
||||
import ol.MapBrowserEvent;
|
||||
import ol.MapEvent;
|
||||
import ol.OLFactory;
|
||||
|
||||
public class OLMapManager {
|
||||
|
||||
private String targetId;
|
||||
private HandlerManager eventBus;
|
||||
private OpenLayerOSM olMap;
|
||||
private ol.Extent dragStartExtent = null;
|
||||
private Double zoomStart = null;
|
||||
private Double zoomEnd = null;
|
||||
private ol.Extent dragEndExtent = null;
|
||||
private static final int QUERY_MIN_ZOOM_LEVEL = 10;
|
||||
|
||||
public OLMapManager(String targetId, HandlerManager eventBus) {
|
||||
this.targetId = targetId;
|
||||
this.eventBus = eventBus;
|
||||
instanceOLMap();
|
||||
}
|
||||
|
||||
public void instanceOLMap() {
|
||||
|
||||
olMap = new OpenLayerOSM(targetId, eventBus) {
|
||||
|
||||
@Override
|
||||
public void clickListener(MapBrowserEvent event) {
|
||||
Coordinate coordinate = event.getCoordinate();
|
||||
if(!olMap.mapInstancied())
|
||||
return;
|
||||
|
||||
if (olMap.isQueryPointActive()) {
|
||||
GeoQuery select = toDataPointQuery(coordinate);
|
||||
eventBus.fireEvent(new QueryDataEvent(select, coordinate));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveEndListener(MapEvent event) {
|
||||
//onInit
|
||||
if(!olMap.mapInstancied())
|
||||
return;
|
||||
|
||||
checkSelectQuery();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moveStartListener(MapEvent event) {
|
||||
|
||||
//onInit
|
||||
if(!olMap.mapInstancied())
|
||||
return;
|
||||
|
||||
setDragStart();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapZoomListener(MapEvent event) {
|
||||
|
||||
//onInit
|
||||
if(!olMap.mapInstancied())
|
||||
return;
|
||||
|
||||
setDragStart();
|
||||
zoomStart = olMap.getCurrentZoomLevel();
|
||||
GWT.log("zoomStart: "+zoomStart);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mapZoomEndListener(MapEvent event) {
|
||||
//onInit
|
||||
//onInit
|
||||
if(!olMap.mapInstancied())
|
||||
return;
|
||||
|
||||
setDragStart();
|
||||
zoomEnd = olMap.getCurrentZoomLevel();
|
||||
GWT.log("zoomEnd: "+zoomEnd);
|
||||
checkSelectQuery();
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// 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);
|
||||
|
||||
olMap.setCenter(transformedCenterCoordinate);
|
||||
olMap.setZoom(GeoportalDataViewerConstants.ITALY_FIT_ZOOM_ON);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* To data point query.
|
||||
*
|
||||
* @param coordinate the coordinate
|
||||
* @return the geo query
|
||||
*/
|
||||
private GeoQuery toDataPointQuery(Coordinate coordinate) {
|
||||
|
||||
double lon = coordinate.getX();
|
||||
double lat = coordinate.getY();
|
||||
|
||||
int w = (int) olMap.getSize().getWidth();
|
||||
int h = (int) olMap.getSize().getHeight();
|
||||
// handler.clickOnMap(x, y, w, h);
|
||||
|
||||
// ratio - mapPixelWeight : bboxWeight = 20px : geoRectangleWidth
|
||||
// where 10px is the pixel diameter dimension of the clicked point
|
||||
double bboxWidth = Math.abs(olMap.getExtent().getLowerLeftX() - olMap.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+")");
|
||||
|
||||
// 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));
|
||||
GeoQuery select = new GeoQuery(x1, y1, x2, y2, TYPE.POINT);
|
||||
return select;
|
||||
}
|
||||
|
||||
public OpenLayerOSM getOLOSMMap() {
|
||||
return olMap;
|
||||
}
|
||||
|
||||
private void checkSelectQuery() {
|
||||
|
||||
GWT.log("Zoom is:" + olMap.getCurrentZoomLevel());
|
||||
|
||||
if (dragStartExtent != null && olMap.getCurrentZoomLevel() > QUERY_MIN_ZOOM_LEVEL) {
|
||||
dragEndExtent = olMap.getExtent();
|
||||
// GWT.log("Drag end is: "+dragEndExtent);
|
||||
ExtentWrapped startExt = new ExtentWrapped(dragStartExtent.getLowerLeftX(), dragStartExtent.getLowerLeftY(),
|
||||
dragStartExtent.getUpperRightX(), dragStartExtent.getUpperRightY());
|
||||
ExtentWrapped endExt = new ExtentWrapped(dragEndExtent.getLowerLeftX(), dragEndExtent.getLowerLeftY(),
|
||||
dragEndExtent.getUpperRightX(), dragEndExtent.getUpperRightY());
|
||||
// GWT.log("start Ext: "+startExt);
|
||||
// GWT.log("endExt Ext: "+endExt);
|
||||
long dist = MapUtils.distanceBetweenCentroid(startExt, endExt);
|
||||
GWT.log("the distance is: " + dist);
|
||||
if (dist > 5000 || startExt.containsExtent(endExt)) {
|
||||
GeoQuery select = toDataBoxQuery(dragEndExtent);
|
||||
eventBus.fireEvent(new QueryDataEvent(select, endExt.getCenter()));
|
||||
}
|
||||
}
|
||||
else if(zoomStart!=null && zoomEnd!=null && zoomEnd<zoomStart) {
|
||||
|
||||
// if(zoomEnd<QUERY_MIN_ZOOM_LEVEL)
|
||||
// olMap.hidePopup();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setDragStart() {
|
||||
if (olMap.getCurrentZoomLevel() > QUERY_MIN_ZOOM_LEVEL) {
|
||||
dragStartExtent = olMap.getExtent();
|
||||
GWT.log("Drag Start is: " + dragStartExtent);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* To data point query.
|
||||
*
|
||||
* @param coordinate the coordinate
|
||||
* @return the geo query
|
||||
*/
|
||||
private GeoQuery toDataBoxQuery(ol.Extent extent) {
|
||||
|
||||
return new GeoQuery(extent.getLowerLeftX(), extent.getLowerLeftY(), extent.getUpperRightX(), extent.getUpperRightY(), TYPE.BOX);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -39,7 +39,7 @@ public class ExtentWrapped extends ol.Extent {
|
|||
*/
|
||||
@JsOverlay
|
||||
public final Coordinate getCenter() {
|
||||
return getCenter(this);
|
||||
return getCenter((ol.Extent) this);
|
||||
}
|
||||
|
||||
@JsMethod(name = "getCenter", namespace = PACKAGE_EXTENT)
|
||||
|
|
|
@ -6,6 +6,7 @@ import ol.control.Control;
|
|||
import ol.control.FullScreen;
|
||||
import ol.control.MousePosition;
|
||||
import ol.control.ZoomSlider;
|
||||
import ol.geom.LineString;
|
||||
import ol.proj.Projection;
|
||||
|
||||
|
||||
|
@ -48,6 +49,38 @@ public final class MapUtils {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Distance between centroid.
|
||||
*
|
||||
* @param ex1 the ex 1
|
||||
* @param ex2 the ex 2
|
||||
* @return the long
|
||||
*/
|
||||
public static long distanceBetweenCentroid(ExtentWrapped ex1, ExtentWrapped ex2) {
|
||||
return distanceBetween(ex1.getCenter(),ex2.getCenter());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Distance between.
|
||||
*
|
||||
* @param c1 the c 1
|
||||
* @param c2 the c 2
|
||||
* @return the long
|
||||
*/
|
||||
public static long distanceBetween(Coordinate c1, Coordinate c2) {
|
||||
|
||||
Coordinate[] arrayCoordinate = new Coordinate[2];
|
||||
arrayCoordinate[0] = c1;
|
||||
arrayCoordinate[1] = c2;
|
||||
|
||||
LineString ls = new LineString(arrayCoordinate);
|
||||
// GWT.log("Line length is: "+ls);
|
||||
return Math.round(ls.getLength() * 100) / 100;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reverse coordinate.
|
||||
*
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.client.gis;
|
||||
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEvent;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery.TYPE;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.dom.client.Style.Visibility;
|
||||
|
@ -16,10 +13,12 @@ import ol.Collection;
|
|||
import ol.Coordinate;
|
||||
import ol.Map;
|
||||
import ol.MapBrowserEvent;
|
||||
import ol.MapEvent;
|
||||
import ol.MapOptions;
|
||||
import ol.OLFactory;
|
||||
import ol.Overlay;
|
||||
import ol.OverlayOptions;
|
||||
import ol.Size;
|
||||
import ol.View;
|
||||
import ol.ViewOptions;
|
||||
import ol.control.Attribution;
|
||||
|
@ -53,8 +52,20 @@ import ol.source.XyzOptions;
|
|||
*
|
||||
* Oct 27, 2020
|
||||
*/
|
||||
public class OpenLayerOSM {
|
||||
public abstract class OpenLayerOSM {
|
||||
|
||||
public abstract void clickListener(MapBrowserEvent event);
|
||||
|
||||
public abstract void moveEndListener(MapEvent event);
|
||||
|
||||
public abstract void moveStartListener(MapEvent event);
|
||||
|
||||
public abstract void mapZoomListener(MapEvent event);
|
||||
|
||||
public abstract void mapZoomEndListener(MapEvent event);
|
||||
|
||||
private static final int QUERY_MIN_ZOOM_LEVEL = 10;
|
||||
|
||||
/** The map. */
|
||||
private Map map;
|
||||
|
||||
|
@ -130,52 +141,59 @@ public class OpenLayerOSM {
|
|||
|
||||
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) {
|
||||
|
||||
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
|
||||
// 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+")");
|
||||
|
||||
// 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));
|
||||
GeoQuery select = new GeoQuery(x1, y1, x2, y2, TYPE.POINT);
|
||||
eventBus.fireEvent(new QueryDataEvent(select,coordinate));
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
map.addControl(attribution);
|
||||
|
||||
|
||||
// add some interactions
|
||||
map.addInteraction(new KeyboardPan());
|
||||
map.addInteraction(new KeyboardZoom());
|
||||
|
||||
bindEvents();
|
||||
|
||||
}
|
||||
|
||||
private void bindEvents() {
|
||||
|
||||
map.addClickListener(new EventListener<MapBrowserEvent>() {
|
||||
|
||||
@Override
|
||||
public void onEvent(MapBrowserEvent event) {
|
||||
clickListener(event);
|
||||
}
|
||||
});
|
||||
|
||||
map.addMoveEndListener(new EventListener<MapEvent>() {
|
||||
|
||||
@Override
|
||||
public void onEvent(MapEvent event) {
|
||||
moveEndListener(event);
|
||||
}
|
||||
});
|
||||
|
||||
map.addMoveStartListener(new EventListener<MapEvent>() {
|
||||
|
||||
@Override
|
||||
public void onEvent(MapEvent event) {
|
||||
moveStartListener(event);
|
||||
}
|
||||
});
|
||||
|
||||
map.addMapZoomListener(new EventListener<MapEvent>() {
|
||||
|
||||
@Override
|
||||
public void onEvent(MapEvent event) {
|
||||
mapZoomListener(event);
|
||||
}
|
||||
});
|
||||
|
||||
map.addMapZoomEndListener(new EventListener<MapEvent>() {
|
||||
|
||||
@Override
|
||||
public void onEvent(MapEvent event) {
|
||||
mapZoomEndListener(event);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the center.
|
||||
*
|
||||
|
@ -208,6 +226,13 @@ public class OpenLayerOSM {
|
|||
popupOverlay.setPosition(coordinate);
|
||||
}
|
||||
|
||||
public void hidePopup() {
|
||||
if(popupOverlay!=null) {
|
||||
Element elPopup = DOM.getElementById("popup");
|
||||
elPopup.getStyle().setVisibility(Visibility.HIDDEN);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the popup closer handelr.
|
||||
*
|
||||
|
@ -438,6 +463,22 @@ public class OpenLayerOSM {
|
|||
return Projection.transform(centerCoordinate, source, target);
|
||||
}
|
||||
|
||||
public boolean isQueryBoxActive() {
|
||||
return isQueryBoxActive;
|
||||
}
|
||||
|
||||
public boolean isQueryPointActive() {
|
||||
return isQueryPointActive;
|
||||
}
|
||||
|
||||
public Size getSize() {
|
||||
return map.getSize();
|
||||
}
|
||||
|
||||
public boolean mapInstancied() {
|
||||
return this.map!=null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,10 @@ import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerCon
|
|||
import org.gcube.portlets.user.geoportaldataviewer.server.util.URLParserUtil;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.Coordinate;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureGeometry;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.FeatureRow;
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs.PointsPath;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
@ -126,8 +128,26 @@ public class FeatureParser {
|
|||
JSONObject geometry = theFeature.getJSONObject("geometry");
|
||||
String typeValue = geometry.getString("type");
|
||||
JSONArray coordinates = geometry.getJSONArray("coordinates");
|
||||
String toCoordinates = coordinates.toString();
|
||||
row.setGeometry(new FeatureGeometry(typeValue, toCoordinates));
|
||||
//String toCoordinates = coordinates.toString();
|
||||
String x1 = coordinates.get(0).toString();
|
||||
String y1 = coordinates.get(1).toString();
|
||||
LOG.debug("Coordinate x1: "+x1);
|
||||
LOG.debug("Coordinate y1: "+y1);
|
||||
Double coordX = null;
|
||||
Double coordY = null;
|
||||
FeatureGeometry fg = new FeatureGeometry();
|
||||
fg.setType(typeValue);
|
||||
//TODO ONLY POINT GEOMETRY
|
||||
try {
|
||||
coordX = Double.parseDouble(x1);
|
||||
coordY = Double.parseDouble(y1);
|
||||
Coordinate coord = new Coordinate(coordX, coordY);
|
||||
fg.setPath(new PointsPath(new Coordinate[] {coord}));
|
||||
}catch (Exception e) {
|
||||
LOG.warn("Not able to parse the 'coordinates' field: ",e);
|
||||
}
|
||||
|
||||
row.setGeometry(fg);
|
||||
}catch (Exception e) {
|
||||
LOG.debug("Unable to pase geometry at index: "+i);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* The Class Coordinate.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Nov 16, 2020
|
||||
*/
|
||||
public class Coordinate implements Serializable{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -3352677110683481305L;
|
||||
|
||||
private Double x;
|
||||
private Double y;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new coordinate.
|
||||
*/
|
||||
public Coordinate() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new coordinate.
|
||||
*
|
||||
* @param x the x
|
||||
* @param y the y
|
||||
*/
|
||||
public Coordinate(Double x, Double y) {
|
||||
super();
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
public Double getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public void setX(Double x) {
|
||||
this.x = x;
|
||||
}
|
||||
|
||||
public Double getY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
public void setY(Double y) {
|
||||
this.y = y;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("Coordinate [x=");
|
||||
builder.append(x);
|
||||
builder.append(", y=");
|
||||
builder.append(y);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -7,24 +7,24 @@ import java.io.Serializable;
|
|||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Oct 29, 2020
|
||||
* Oct 29, 2020
|
||||
*/
|
||||
public class FeatureGeometry implements Serializable{
|
||||
|
||||
public class FeatureGeometry implements WFSGeometry, Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 6251162740446739453L;
|
||||
private String type;
|
||||
private String coordinates;
|
||||
|
||||
private PointsPath path;
|
||||
|
||||
public FeatureGeometry() {
|
||||
}
|
||||
|
||||
public FeatureGeometry(String type, String coordinates) {
|
||||
|
||||
public FeatureGeometry(String type, PointsPath path) {
|
||||
super();
|
||||
this.type = type;
|
||||
this.coordinates = coordinates;
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
|
@ -35,12 +35,12 @@ public class FeatureGeometry implements Serializable{
|
|||
this.type = type;
|
||||
}
|
||||
|
||||
public String getCoordinates() {
|
||||
return coordinates;
|
||||
public PointsPath getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setCoordinates(String coordinates) {
|
||||
this.coordinates = coordinates;
|
||||
public void setPath(PointsPath path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -48,8 +48,8 @@ public class FeatureGeometry implements Serializable{
|
|||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("FeatureGeometry [type=");
|
||||
builder.append(type);
|
||||
builder.append(", coordinates=");
|
||||
builder.append(coordinates);
|
||||
builder.append(", path=");
|
||||
builder.append(path);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
|
||||
|
||||
/**
|
||||
* The Class PointsPath.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Nov 16, 2020
|
||||
*/
|
||||
public class PointsPath implements Serializable{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -3295493507974317970L;
|
||||
|
||||
private Coordinate[] coordinates;
|
||||
|
||||
/**
|
||||
* Instantiates a new points path.
|
||||
*/
|
||||
public PointsPath() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiates a new points path.
|
||||
*
|
||||
* @param coordinates the coordinates
|
||||
*/
|
||||
public PointsPath(Coordinate[] coordinates) {
|
||||
super();
|
||||
this.coordinates = coordinates;
|
||||
}
|
||||
|
||||
public Coordinate[] getCoordinates() {
|
||||
return coordinates;
|
||||
}
|
||||
|
||||
/**
|
||||
* To string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("PointsPath [coordinates=");
|
||||
builder.append(Arrays.toString(coordinates));
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.shared.gis.wfs;
|
||||
|
||||
|
||||
/**
|
||||
* The Interface WFSGeometry.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Nov 16, 2020
|
||||
*/
|
||||
public interface WFSGeometry {
|
||||
|
||||
/**
|
||||
* Gets the type.
|
||||
*
|
||||
* @return the type
|
||||
*/
|
||||
String getType();
|
||||
|
||||
|
||||
/**
|
||||
* Gets the path.
|
||||
*
|
||||
* @return the path
|
||||
*/
|
||||
PointsPath getPath();
|
||||
|
||||
}
|
Loading…
Reference in New Issue