in progress on WFS interaction
This commit is contained in:
parent
eb0b78da87
commit
8e7071bf6f
|
@ -1,4 +1,4 @@
|
||||||
eclipse.preferences.version=1
|
eclipse.preferences.version=1
|
||||||
lastWarOutDir=/home/francesco/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-1.0.0-SNAPSHOT
|
lastWarOutDir=/home/francesco-mangiacrapa/git/geoportal-data-viewer-app/target/geoportal-data-viewer-app-1.0.0-SNAPSHOT
|
||||||
warSrcDir=src/main/webapp
|
warSrcDir=src/main/webapp
|
||||||
warSrcDirIsOutput=false
|
warSrcDirIsOutput=false
|
||||||
|
|
59
pom.xml
59
pom.xml
|
@ -48,29 +48,29 @@
|
||||||
</developers>
|
</developers>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
<!-- <dependencies> -->
|
<!-- <dependencies> -->
|
||||||
<!-- <dependency> -->
|
<!-- <dependency> -->
|
||||||
<!-- <groupId>org.gcube.distribution</groupId> -->
|
<!-- <groupId>org.gcube.distribution</groupId> -->
|
||||||
<!-- <artifactId>maven-portal-bom</artifactId> -->
|
<!-- <artifactId>maven-portal-bom</artifactId> -->
|
||||||
<!-- <version>3.6.0</version> -->
|
<!-- <version>3.6.0</version> -->
|
||||||
<!-- <type>pom</type> -->
|
<!-- <type>pom</type> -->
|
||||||
<!-- <scope>import</scope> -->
|
<!-- <scope>import</scope> -->
|
||||||
<!-- <exclusions> -->
|
<!-- <exclusions> -->
|
||||||
<!-- <exclusion> -->
|
<!-- <exclusion> -->
|
||||||
<!-- <groupId>com.google.gwt</groupId> -->
|
<!-- <groupId>com.google.gwt</groupId> -->
|
||||||
<!-- <artifactId>gwt-user</artifactId> -->
|
<!-- <artifactId>gwt-user</artifactId> -->
|
||||||
<!-- </exclusion> -->
|
<!-- </exclusion> -->
|
||||||
<!-- <exclusion> -->
|
<!-- <exclusion> -->
|
||||||
<!-- <groupId>com.google.gwt</groupId> -->
|
<!-- <groupId>com.google.gwt</groupId> -->
|
||||||
<!-- <artifactId>gwt-servlet</artifactId> -->
|
<!-- <artifactId>gwt-servlet</artifactId> -->
|
||||||
<!-- </exclusion> -->
|
<!-- </exclusion> -->
|
||||||
<!-- <exclusion> -->
|
<!-- <exclusion> -->
|
||||||
<!-- <groupId>com.google.gwt</groupId> -->
|
<!-- <groupId>com.google.gwt</groupId> -->
|
||||||
<!-- <artifactId>gwt-dev</artifactId> -->
|
<!-- <artifactId>gwt-dev</artifactId> -->
|
||||||
<!-- </exclusion> -->
|
<!-- </exclusion> -->
|
||||||
<!-- </exclusions> -->
|
<!-- </exclusions> -->
|
||||||
<!-- </dependency> -->
|
<!-- </dependency> -->
|
||||||
<!-- </dependencies> -->
|
<!-- </dependencies> -->
|
||||||
</dependencyManagement>
|
</dependencyManagement>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
@ -114,7 +114,18 @@
|
||||||
<version>[2.4.1,3.0.0-SNAPSHOT)</version>
|
<version>[2.4.1,3.0.0-SNAPSHOT)</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.application</groupId>
|
||||||
|
<artifactId>geoportal-logic</artifactId>
|
||||||
|
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<groupId>javax.servlet</groupId>
|
||||||
|
<artifactId>servlet-api</artifactId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.liferay.portal</groupId>
|
<groupId>com.liferay.portal</groupId>
|
||||||
<artifactId>portal-service</artifactId>
|
<artifactId>portal-service</artifactId>
|
||||||
|
|
|
@ -50,6 +50,8 @@ public class GeoportalDataViewer implements EntryPoint {
|
||||||
/** The layer manager. */
|
/** The layer manager. */
|
||||||
private LayerManager layerManager = new LayerManager();
|
private LayerManager layerManager = new LayerManager();
|
||||||
|
|
||||||
|
//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
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the entry point method.
|
* This is the entry point method.
|
||||||
*/
|
*/
|
||||||
|
@ -63,7 +65,7 @@ public class GeoportalDataViewer implements EntryPoint {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
olMap = new OpenLayerOSM(mainPanel.getMapPanel().getElement().getId());
|
olMap = new OpenLayerOSM(mainPanel.getMapPanel().getElement().getId(),layerManager.getEventBus());
|
||||||
layerManager.setOlMap(olMap);
|
layerManager.setOlMap(olMap);
|
||||||
mainPanel.setMap(olMap);
|
mainPanel.setMap(olMap);
|
||||||
|
|
||||||
|
|
|
@ -18,4 +18,6 @@ public class GeoportalDataViewerConstants {
|
||||||
|
|
||||||
public enum LayerType {RASTER_BASELAYER, FEATURE_TYPE};
|
public enum LayerType {RASTER_BASELAYER, FEATURE_TYPE};
|
||||||
|
|
||||||
|
public static final int MAX_WFS_FEATURES = 5; // zero for no limit
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
package org.gcube.portlets.user.geoportaldataviewer.client;
|
package org.gcube.portlets.user.geoportaldataviewer.client;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataObject;
|
||||||
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap;
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoInformationForWMSRequest;
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoInformationForWMSRequest;
|
||||||
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
|
||||||
|
|
||||||
import com.google.gwt.user.client.rpc.RemoteService;
|
import com.google.gwt.user.client.rpc.RemoteService;
|
||||||
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
||||||
|
@ -13,4 +18,7 @@ public interface GeoportalDataViewerService extends RemoteService {
|
||||||
|
|
||||||
GeoInformationForWMSRequest parseWmsRequest(String wmsRequest, String layerName) throws Exception;
|
GeoInformationForWMSRequest parseWmsRequest(String wmsRequest, String layerName) throws Exception;
|
||||||
|
|
||||||
|
List<GeoNaDataObject> getDataResult(List<LayerItem> layerItems, String mapSrsName, BoundsMap mapBBOX,
|
||||||
|
int maxWFSFeature, double zoomLevel);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
package org.gcube.portlets.user.geoportaldataviewer.client;
|
package org.gcube.portlets.user.geoportaldataviewer.client;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataObject;
|
||||||
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap;
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoInformationForWMSRequest;
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoInformationForWMSRequest;
|
||||||
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
|
||||||
|
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
@ -25,4 +30,7 @@ public interface GeoportalDataViewerServiceAsync {
|
||||||
}
|
}
|
||||||
|
|
||||||
void parseWmsRequest(String wmsRequest, String layerName, AsyncCallback<GeoInformationForWMSRequest> callback);
|
void parseWmsRequest(String wmsRequest, String layerName, AsyncCallback<GeoInformationForWMSRequest> callback);
|
||||||
|
|
||||||
|
void getDataResult(List<LayerItem> layerItems, String mapSrsName, BoundsMap mapBBOX, int maxWFSFeature, double zoomLevel,
|
||||||
|
AsyncCallback<List<GeoNaDataObject>> callback);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,17 +5,23 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.LayerType;
|
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants.LayerType;
|
||||||
|
import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEvent;
|
||||||
|
import org.gcube.portlets.user.geoportaldataviewer.client.events.QueryDataEventHandler;
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM;
|
import org.gcube.portlets.user.geoportaldataviewer.client.gis.OpenLayerOSM;
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil;
|
import org.gcube.portlets.user.geoportaldataviewer.client.util.URLUtil;
|
||||||
|
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataObject;
|
||||||
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap;
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoInformationForWMSRequest;
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoInformationForWMSRequest;
|
||||||
|
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.LayerItem;
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.ZAxis;
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.ZAxis;
|
||||||
|
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.event.shared.HandlerManager;
|
||||||
import com.google.gwt.user.client.Window;
|
import com.google.gwt.user.client.Window;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
|
||||||
// TODO: Auto-generated Javadoc
|
|
||||||
/**
|
/**
|
||||||
* The Class LayerManager.
|
* The Class LayerManager.
|
||||||
*
|
*
|
||||||
|
@ -31,10 +37,52 @@ public class LayerManager {
|
||||||
/** The layer items. */
|
/** The layer items. */
|
||||||
private List<LayerItem> layerItems = new ArrayList<LayerItem>();
|
private List<LayerItem> layerItems = new ArrayList<LayerItem>();
|
||||||
|
|
||||||
|
private HandlerManager eventBus = new HandlerManager("");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new layer manager.
|
* Instantiates a new layer manager.
|
||||||
*/
|
*/
|
||||||
public LayerManager() {
|
public LayerManager() {
|
||||||
|
bindEvents();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void bindEvents() {
|
||||||
|
|
||||||
|
eventBus.addHandler(QueryDataEvent.TYPE, new QueryDataEventHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onQueryInteraction(QueryDataEvent queryEvent) {
|
||||||
|
|
||||||
|
if(queryEvent.getGeoQuery()!=null) {
|
||||||
|
GeoQuery selectDataInfo = queryEvent.getGeoQuery();
|
||||||
|
GWT.log("("+selectDataInfo.getX1()+","+selectDataInfo.getY1()+")("+selectDataInfo.getX2()+","+selectDataInfo.getY2()+")");
|
||||||
|
|
||||||
|
for (LayerItem layerItem : layerItems){
|
||||||
|
//TODO
|
||||||
|
isLayerVisible(layerItem);
|
||||||
|
|
||||||
|
}
|
||||||
|
BoundsMap mapBBOX = new BoundsMap();
|
||||||
|
mapBBOX.setCrs(olMap.getProjectionCode());
|
||||||
|
mapBBOX.setLowerLeftX(olMap.getExtent().getLowerLeftX());
|
||||||
|
mapBBOX.setLowerLeftY(olMap.getExtent().getLowerLeftY());
|
||||||
|
mapBBOX.setUpperRightX(olMap.getExtent().getUpperRightX());
|
||||||
|
mapBBOX.setUpperRightY(olMap.getExtent().getUpperRightY());
|
||||||
|
|
||||||
|
GeoportalDataViewerServiceAsync.Util.getInstance().getDataResult(layerItems, olMap.getProjectionCode(), mapBBOX, GeoportalDataViewerConstants.MAX_WFS_FEATURES, olMap.getCurrentZoomLevel(), new AsyncCallback<List<GeoNaDataObject>>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(List<GeoNaDataObject> result) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -119,20 +167,20 @@ public class LayerManager {
|
||||||
private void addLayerByWms(LayerType layerType, String layerTitle, String layerName, String layerURL, String mapServerHost, boolean isExternal, boolean isBase, boolean displayInLayerSwitcher, ArrayList<String> styles, String serverWmsRequest, boolean onTop, HashMap<String, String> wmsNotStandardParams, boolean isNcWms, String UUID, ZAxis zAxis) {
|
private void addLayerByWms(LayerType layerType, String layerTitle, String layerName, String layerURL, String mapServerHost, boolean isExternal, boolean isBase, boolean displayInLayerSwitcher, ArrayList<String> styles, String serverWmsRequest, boolean onTop, HashMap<String, String> wmsNotStandardParams, boolean isNcWms, String UUID, ZAxis zAxis) {
|
||||||
|
|
||||||
// GWT.log("Add addLayerByWms 1");
|
// GWT.log("Add addLayerByWms 1");
|
||||||
LayerItem l = new LayerItem();
|
LayerItem layerItem = new LayerItem();
|
||||||
l.setBaseLayer(isBase);
|
layerItem.setBaseLayer(isBase);
|
||||||
l.setTitle(layerTitle);
|
layerItem.setTitle(layerTitle);
|
||||||
l.setName(layerName);
|
layerItem.setName(layerName);
|
||||||
l.setUrl(layerURL);
|
layerItem.setUrl(layerURL);
|
||||||
l.setMapServerHost(mapServerHost);
|
layerItem.setMapServerHost(mapServerHost);
|
||||||
//l.setExternal(isExternal);
|
//l.setExternal(isExternal);
|
||||||
l.setOpacity(1d);
|
layerItem.setOpacity(1d);
|
||||||
l.setBuffer(2);
|
layerItem.setBuffer(2);
|
||||||
l.setServerWmsRequest(serverWmsRequest);
|
layerItem.setServerWmsRequest(serverWmsRequest);
|
||||||
l.setWmsNotStandardParams(wmsNotStandardParams);
|
layerItem.setWmsNotStandardParams(wmsNotStandardParams);
|
||||||
l.setNcWms(isNcWms);
|
layerItem.setNcWms(isNcWms);
|
||||||
l.setUUID(UUID);
|
layerItem.setUUID(UUID);
|
||||||
l.setZAxis(zAxis);
|
layerItem.setZAxis(zAxis);
|
||||||
|
|
||||||
switch (layerType) {
|
switch (layerType) {
|
||||||
|
|
||||||
|
@ -140,17 +188,17 @@ public class LayerManager {
|
||||||
case RASTER_BASELAYER:
|
case RASTER_BASELAYER:
|
||||||
|
|
||||||
// l.setHasLegend(false);
|
// l.setHasLegend(false);
|
||||||
l.setBaseLayer(true);
|
layerItem.setBaseLayer(true);
|
||||||
l.setTrasparent(false);
|
layerItem.setTrasparent(false);
|
||||||
l.setClickData(false);
|
layerItem.setClickData(false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FEATURE_TYPE:
|
case FEATURE_TYPE:
|
||||||
|
|
||||||
//CASE FEATURE TYPE
|
//CASE FEATURE TYPE
|
||||||
l.setBaseLayer(false);
|
layerItem.setBaseLayer(false);
|
||||||
l.setClickData(true);
|
layerItem.setClickData(true);
|
||||||
l.setTrasparent(true);
|
layerItem.setTrasparent(true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -158,20 +206,20 @@ public class LayerManager {
|
||||||
GWT.log("styles "+styles);
|
GWT.log("styles "+styles);
|
||||||
|
|
||||||
if(styles!=null && styles.size()>0){
|
if(styles!=null && styles.size()>0){
|
||||||
l.setHasLegend(true);
|
layerItem.setHasLegend(true);
|
||||||
l.setDefaultStyle(styles.get(0));
|
layerItem.setDefaultStyle(styles.get(0));
|
||||||
l.setStyle(styles.get(0));
|
layerItem.setStyle(styles.get(0));
|
||||||
l.setStyles(styles);
|
layerItem.setStyles(styles);
|
||||||
}else{
|
}else{
|
||||||
String style = URLUtil.getValueOfParameter("styles", serverWmsRequest);
|
String style = URLUtil.getValueOfParameter("styles", serverWmsRequest);
|
||||||
if(style!=null){ //CASE OF STYLE ="";
|
if(style!=null){ //CASE OF STYLE ="";
|
||||||
//TENTATIVE TO GET LEGEND
|
//TENTATIVE TO GET LEGEND
|
||||||
l.setHasLegend(true);
|
layerItem.setHasLegend(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GWT.log("Built layer: "+l);
|
GWT.log("Built layer: "+layerItem);
|
||||||
layerItems.add(l);
|
layerItems.add(layerItem);
|
||||||
olMap.addWMSLayer(l.getMapServerHost(), layerName);
|
olMap.addWMSLayer(layerItem.getMapServerHost(), layerName);
|
||||||
|
|
||||||
// openLayersMap.addLayerItemByWms(l, displayInLayerSwitcher);
|
// openLayersMap.addLayerItemByWms(l, displayInLayerSwitcher);
|
||||||
// layersPanel.addLayerItems(layerItems, onTop);
|
// layersPanel.addLayerItems(layerItems, onTop);
|
||||||
|
@ -179,6 +227,17 @@ public class LayerManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if is layer visible.
|
||||||
|
*
|
||||||
|
* @param layerItem the layer item
|
||||||
|
* @return true, if is layer visible
|
||||||
|
*/
|
||||||
|
public boolean isLayerVisible(LayerItem layerItem){
|
||||||
|
return olMap.isLayerVisible(layerItem.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the ol map.
|
* Sets the ol map.
|
||||||
*
|
*
|
||||||
|
@ -188,6 +247,11 @@ public class LayerManager {
|
||||||
this.olMap = olMap;
|
this.olMap = olMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HandlerManager getEventBus() {
|
||||||
|
return eventBus;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
package org.gcube.portlets.user.geoportaldataviewer.client.events;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoQuery;
|
||||||
|
|
||||||
|
import com.google.gwt.event.shared.GwtEvent;
|
||||||
|
|
||||||
|
import ol.Coordinate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class QueryDataEvent.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
*
|
||||||
|
* Oct 29, 2020
|
||||||
|
*/
|
||||||
|
public class QueryDataEvent extends GwtEvent<QueryDataEventHandler> {
|
||||||
|
public static Type<QueryDataEventHandler> TYPE = new Type<QueryDataEventHandler>();
|
||||||
|
private GeoQuery select;
|
||||||
|
private Coordinate oLCoordinate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new table row selected event.
|
||||||
|
* @param coordinate
|
||||||
|
*/
|
||||||
|
public QueryDataEvent(GeoQuery select, Coordinate coordinate) {
|
||||||
|
this.select = select;
|
||||||
|
this.oLCoordinate = coordinate;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the associated type.
|
||||||
|
*
|
||||||
|
* @return the associated type
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Type<QueryDataEventHandler> getAssociatedType() {
|
||||||
|
return TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Dispatch.
|
||||||
|
*
|
||||||
|
* @param handler the handler
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void dispatch(QueryDataEventHandler handler) {
|
||||||
|
handler.onQueryInteraction(this);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public GeoQuery getGeoQuery() {
|
||||||
|
return select;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Coordinate getoLCoordinate() {
|
||||||
|
return oLCoordinate;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package org.gcube.portlets.user.geoportaldataviewer.client.events;
|
||||||
|
|
||||||
|
import com.google.gwt.event.shared.EventHandler;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Interface QueryDataEventHandler.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
*
|
||||||
|
* Oct 29, 2020
|
||||||
|
*/
|
||||||
|
public interface QueryDataEventHandler extends EventHandler {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On query interaction.
|
||||||
|
*
|
||||||
|
* @param query the query
|
||||||
|
*/
|
||||||
|
void onQueryInteraction(QueryDataEvent query);
|
||||||
|
}
|
|
@ -18,7 +18,6 @@ import ol.control.ControlOptions;
|
||||||
import ol.control.FullScreen;
|
import ol.control.FullScreen;
|
||||||
import ol.control.MousePosition;
|
import ol.control.MousePosition;
|
||||||
import ol.control.ZoomSlider;
|
import ol.control.ZoomSlider;
|
||||||
import ol.control.ZoomToExtent;
|
|
||||||
import ol.geom.Polygon;
|
import ol.geom.Polygon;
|
||||||
import ol.layer.Base;
|
import ol.layer.Base;
|
||||||
import ol.layer.LayerOptions;
|
import ol.layer.LayerOptions;
|
||||||
|
@ -49,7 +48,7 @@ public final class DemoUtils {
|
||||||
MousePosition mousePosition = new MousePosition();
|
MousePosition mousePosition = new MousePosition();
|
||||||
mousePosition.setCoordinateFormat(Coordinate.createStringXY(5));
|
mousePosition.setCoordinateFormat(Coordinate.createStringXY(5));
|
||||||
controls.push(mousePosition);
|
controls.push(mousePosition);
|
||||||
controls.push(new ZoomToExtent());
|
//controls.push(new ZoomToExtent());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
package org.gcube.portlets.user.geoportaldataviewer.client.gis;
|
package org.gcube.portlets.user.geoportaldataviewer.client.gis;
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
|
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
|
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.core.client.GWT;
|
||||||
|
import com.google.gwt.event.shared.HandlerManager;
|
||||||
import com.google.gwt.user.client.DOM;
|
import com.google.gwt.user.client.DOM;
|
||||||
import com.google.gwt.user.client.Element;
|
import com.google.gwt.user.client.Element;
|
||||||
import com.google.gwt.user.client.Event;
|
import com.google.gwt.user.client.Event;
|
||||||
|
@ -21,7 +23,6 @@ import ol.View;
|
||||||
import ol.ViewOptions;
|
import ol.ViewOptions;
|
||||||
import ol.control.Attribution;
|
import ol.control.Attribution;
|
||||||
import ol.event.EventListener;
|
import ol.event.EventListener;
|
||||||
import ol.geom.Point;
|
|
||||||
import ol.interaction.Draw;
|
import ol.interaction.Draw;
|
||||||
import ol.interaction.DrawOptions;
|
import ol.interaction.DrawOptions;
|
||||||
import ol.interaction.Extent;
|
import ol.interaction.Extent;
|
||||||
|
@ -29,6 +30,7 @@ import ol.interaction.ExtentOptions;
|
||||||
import ol.interaction.Interaction;
|
import ol.interaction.Interaction;
|
||||||
import ol.interaction.KeyboardPan;
|
import ol.interaction.KeyboardPan;
|
||||||
import ol.interaction.KeyboardZoom;
|
import ol.interaction.KeyboardZoom;
|
||||||
|
import ol.layer.Base;
|
||||||
import ol.layer.Image;
|
import ol.layer.Image;
|
||||||
import ol.layer.LayerOptions;
|
import ol.layer.LayerOptions;
|
||||||
import ol.layer.Tile;
|
import ol.layer.Tile;
|
||||||
|
@ -72,15 +74,24 @@ public class OpenLayerOSM {
|
||||||
/** The popup overlay. */
|
/** The popup overlay. */
|
||||||
private Overlay popupOverlay;
|
private Overlay popupOverlay;
|
||||||
|
|
||||||
|
private HandlerManager eventBus;
|
||||||
|
|
||||||
|
private boolean isQueryBoxActive;
|
||||||
|
|
||||||
|
private boolean isQueryPointActive;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new open layer OSM.
|
* Instantiates a new open layer OSM.
|
||||||
*
|
*
|
||||||
* @param divTargetId the div target id
|
* @param divTargetId the div target id
|
||||||
|
* @param eventBus the event bus
|
||||||
*/
|
*/
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see de.desjardins.ol3.demo.client.example.Example#show()
|
* @see de.desjardins.ol3.demo.client.example.Example#show()
|
||||||
*/
|
*/
|
||||||
public OpenLayerOSM(String divTargetId) {
|
public OpenLayerOSM(String divTargetId, HandlerManager eventBus) {
|
||||||
|
this.eventBus = eventBus;
|
||||||
|
|
||||||
// create a OSM-layer
|
// create a OSM-layer
|
||||||
XyzOptions osmSourceOptions = OLFactory.createOptions();
|
XyzOptions osmSourceOptions = OLFactory.createOptions();
|
||||||
|
@ -132,7 +143,7 @@ public class OpenLayerOSM {
|
||||||
public void onEvent(MapBrowserEvent event) {
|
public void onEvent(MapBrowserEvent event) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
Coordinate coordinate = event.getCoordinate();
|
Coordinate coordinate = event.getCoordinate();
|
||||||
if(queryPoint!=null && queryPoint.getActive()) {
|
if(isQueryPointActive) {
|
||||||
|
|
||||||
double lon = coordinate.getX();
|
double lon = coordinate.getX();
|
||||||
double lat = coordinate.getY();
|
double lat = coordinate.getY();
|
||||||
|
@ -149,22 +160,19 @@ public class OpenLayerOSM {
|
||||||
double x2 = Math.max(lon+geoWidth, lon-geoWidth);
|
double x2 = Math.max(lon+geoWidth, lon-geoWidth);
|
||||||
double y1 = Math.min(lat+geoWidth, lat-geoWidth);
|
double y1 = Math.min(lat+geoWidth, lat-geoWidth);
|
||||||
double y2 = Math.max(lat+geoWidth, lat-geoWidth);
|
double y2 = Math.max(lat+geoWidth, lat-geoWidth);
|
||||||
GWT.log("("+x1+","+y1+")("+x2+","+y2+")");
|
//GWT.log("("+x1+","+y1+")("+x2+","+y2+")");
|
||||||
|
|
||||||
Point pt = new Point(coordinate);
|
// Point pt = new Point(coordinate);
|
||||||
ol.Extent extent = pt.getExtent();
|
// ol.Extent extent = pt.getExtent();
|
||||||
selectBox(x1, y1, x2, y2);
|
// //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));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(popupOverlay==null) {
|
|
||||||
Element elPopup = DOM.getElementById("popup");
|
|
||||||
popupOverlay = addOverlay(elPopup);
|
|
||||||
addPopupCloserHandelr(popupOverlay);
|
|
||||||
}
|
|
||||||
Element popContent = DOM.getElementById("popup-content");
|
|
||||||
popContent.setInnerHTML("<p>You clicked here:</p><code>" + coordinate + "</code>");;
|
|
||||||
popupOverlay.setPosition(coordinate);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -176,13 +184,15 @@ public class OpenLayerOSM {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void showPopup(String html, Coordinate coordinate) {
|
||||||
* Gets the extent.
|
if(popupOverlay==null) {
|
||||||
*
|
Element elPopup = DOM.getElementById("popup");
|
||||||
* @return the extent
|
popupOverlay = addOverlay(elPopup);
|
||||||
*/
|
addPopupCloserHandelr(popupOverlay);
|
||||||
public ol.Extent getExtent() {
|
}
|
||||||
return this.map.getView().calculateExtent(map.getSize());
|
Element popContent = DOM.getElementById("popup-content");
|
||||||
|
popContent.setInnerHTML(html);
|
||||||
|
popupOverlay.setPosition(coordinate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -224,7 +234,9 @@ public class OpenLayerOSM {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds the WMS layer.
|
* Adds the WMS layer.
|
||||||
* @throws MalformedURLException
|
*
|
||||||
|
* @param mapServerHost the map server host
|
||||||
|
* @param layerName the layer name
|
||||||
*/
|
*/
|
||||||
public void addWMSLayer(String mapServerHost, String layerName) {
|
public void addWMSLayer(String mapServerHost, String layerName) {
|
||||||
|
|
||||||
|
@ -243,6 +255,8 @@ public class OpenLayerOSM {
|
||||||
|
|
||||||
Image wmsLayer = new Image(layerOptions);
|
Image wmsLayer = new Image(layerOptions);
|
||||||
|
|
||||||
|
//visibleLayerItems
|
||||||
|
|
||||||
map.addLayer(wmsLayer);
|
map.addLayer(wmsLayer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,6 +271,7 @@ public class OpenLayerOSM {
|
||||||
initPointInteraction();
|
initPointInteraction();
|
||||||
|
|
||||||
map.addInteraction(queryPoint);
|
map.addInteraction(queryPoint);
|
||||||
|
isQueryPointActive = true;
|
||||||
return queryPoint;
|
return queryPoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -300,10 +315,8 @@ public class OpenLayerOSM {
|
||||||
if(interactions!=null) {
|
if(interactions!=null) {
|
||||||
map.removeInteraction(queryBox);
|
map.removeInteraction(queryBox);
|
||||||
map.removeInteraction(queryPoint);
|
map.removeInteraction(queryPoint);
|
||||||
//for (int i = 0; i < inters.length; i++) {
|
isQueryBoxActive = false;
|
||||||
// Interaction inter = inters[i];
|
isQueryPointActive = false;
|
||||||
// map.removeInteraction(inter);
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,6 +334,7 @@ public class OpenLayerOSM {
|
||||||
//extentOptions.setBoxStyle(new ol.style.Style(styleOptions));
|
//extentOptions.setBoxStyle(new ol.style.Style(styleOptions));
|
||||||
queryBox = new Extent(extentOptions);
|
queryBox = new Extent(extentOptions);
|
||||||
map.addInteraction(queryBox);
|
map.addInteraction(queryBox);
|
||||||
|
isQueryBoxActive = true;
|
||||||
return queryBox;
|
return queryBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -343,15 +357,70 @@ public class OpenLayerOSM {
|
||||||
return overlay;
|
return overlay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if is layer visible.
|
||||||
|
*
|
||||||
|
* @param layerName the layer name
|
||||||
|
* @return true, if is layer visible
|
||||||
|
*/
|
||||||
|
public boolean isLayerVisible(String layerName) {
|
||||||
|
|
||||||
public void selectBox(double x1, double y1, double x2, double y2) {
|
Collection<Base> layers = map.getLayers();
|
||||||
//ClickDataInfo cdi = new ClickDataInfo(x1, y1, x2, y2);
|
|
||||||
GWT.log("("+x1+","+y1+")("+x2+","+y2+")");
|
|
||||||
|
|
||||||
|
if(layers!=null) {
|
||||||
|
Base[] layersArr = layers.getArray();
|
||||||
|
for (int i = 0; i < layersArr.length; i++) {
|
||||||
|
Base layer = layersArr[i];
|
||||||
|
String theLayerName = (String) layer.get("name");
|
||||||
|
GWT.log("The Layer name is: "+layerName);
|
||||||
|
if(theLayerName!=null && theLayerName.equals(layerName))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the projection code.
|
||||||
|
*
|
||||||
|
* @return the projection code
|
||||||
|
*/
|
||||||
|
public String getProjectionCode() {
|
||||||
|
return map.getView().getProjection().getCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current zoom level.
|
||||||
|
*
|
||||||
|
* @return the current zoom level
|
||||||
|
*/
|
||||||
|
public double getCurrentZoomLevel() {
|
||||||
|
return map.getView().getZoom();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the bbox.
|
||||||
|
*
|
||||||
|
* @return the bbox
|
||||||
|
*/
|
||||||
|
public ol.Extent getBBOX() {
|
||||||
|
return getExtent();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the extent.
|
||||||
|
*
|
||||||
|
* @return the extent
|
||||||
|
*/
|
||||||
|
public ol.Extent getExtent() {
|
||||||
|
return this.map.getView().calculateExtent(map.getSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,273 +0,0 @@
|
||||||
package org.gcube.portlets.user.geoportaldataviewer.client.util;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.client.util.MapServerRecognize.SERVERTYPE;
|
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.ClickDataInfo;
|
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
|
|
||||||
|
|
||||||
import com.google.gwt.core.shared.GWT;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The Class URLMakers.
|
|
||||||
*
|
|
||||||
* @author Ceras. Updated by Francesco Mangiacrapa
|
|
||||||
* francesco.mangiacrapa@isti.cnr.it Jan 28, 2016
|
|
||||||
*/
|
|
||||||
public class URLMakers {
|
|
||||||
|
|
||||||
public static final String CQL_FILTER_PARAMETER = "CQL_FILTER";
|
|
||||||
|
|
||||||
// MAP SERVER PIVOT
|
|
||||||
public static final String WXS = "wxs";
|
|
||||||
// GEOSERVER PIVOT
|
|
||||||
public static final String WMS = "/wms";
|
|
||||||
|
|
||||||
// OUTPUT FORMAT
|
|
||||||
public static final String CSV = "csv";
|
|
||||||
|
|
||||||
public static final String JSON = "json";
|
|
||||||
|
|
||||||
private static String[][] a = { { "\\?", "%3F" }, { "&", "%26" }, };
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * Encoding layer.
|
|
||||||
// *
|
|
||||||
// * @param l the l
|
|
||||||
// * @return the string
|
|
||||||
// */
|
|
||||||
// private static String encodingLayer(String l) {
|
|
||||||
// String result = l.replace(":", "%3A");
|
|
||||||
//
|
|
||||||
// return result;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Gets the url.
|
|
||||||
// *
|
|
||||||
// * @param projection the projection
|
|
||||||
// * @param width the width
|
|
||||||
// * @param height the height
|
|
||||||
// * @param x the x
|
|
||||||
// * @param y the y
|
|
||||||
// * @param bbox the bbox
|
|
||||||
// * @param layers the layers
|
|
||||||
// * @return the url
|
|
||||||
// */
|
|
||||||
// public static String getURL(String projection, String width, String height, int x, int y, String bbox,
|
|
||||||
// Vector<String> layers) {
|
|
||||||
//
|
|
||||||
// String layer = "";
|
|
||||||
// boolean first = true;
|
|
||||||
// for (String s : layers) {
|
|
||||||
// if (!first) {
|
|
||||||
// layer = layer + "%2C" + encodingLayer(s);
|
|
||||||
// }
|
|
||||||
// if (first) {
|
|
||||||
// layer = encodingLayer(s);
|
|
||||||
// }
|
|
||||||
// first = false;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// String[] _bbox = bbox.split(",");
|
|
||||||
//
|
|
||||||
// projection = encodingLayer(projection);
|
|
||||||
// String result = "?REQUEST=GetFeatureInfo&EXCEPTIONS=application%2Fvnd.ogc.se_xml&BBOX=" + _bbox[0] + "%2C"
|
|
||||||
// + _bbox[1] + "%2C" + _bbox[2] + "%2C" + _bbox[3] + "&X=" + x + "&Y=" + y
|
|
||||||
// + "&INFO_FORMAT=text%2Fhtml&QUERY_LAYERS=" + layer + "&FEATURE_COUNT=50&Layers=" + layer
|
|
||||||
// + "&Styles=&Srs=" + projection + "&WIDTH=" + width + "&HEIGHT=" + height + "&format=image%2Fpng";
|
|
||||||
//
|
|
||||||
// return result;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Gets the url.
|
|
||||||
// *
|
|
||||||
// * @param projection the projection
|
|
||||||
// * @param width the width
|
|
||||||
// * @param height the height
|
|
||||||
// * @param x the x
|
|
||||||
// * @param y the y
|
|
||||||
// * @param bbox the bbox
|
|
||||||
// * @param layerItems the layer items
|
|
||||||
// * @return the url
|
|
||||||
// */
|
|
||||||
// public static String getURL(String projection, int width, int height, int x, int y, String bbox,
|
|
||||||
// List<LayerItem> layerItems) {
|
|
||||||
// String strListLayers = "";
|
|
||||||
// boolean first = true;
|
|
||||||
// for (LayerItem layerItem : layerItems) {
|
|
||||||
// if (layerItem.isClickData()) {
|
|
||||||
// String strLayer = encodingLayer(layerItem.getName());
|
|
||||||
// strListLayers = first ? strLayer : strListLayers + "%2C" + strLayer;
|
|
||||||
// first = false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// String[] _bbox = bbox.split(",");
|
|
||||||
//
|
|
||||||
// projection = encodingLayer(projection);
|
|
||||||
// String result = "?REQUEST=GetFeatureInfo&EXCEPTIONS=application%2Fvnd.ogc.se_xml&BBOX=" + _bbox[0] + "%2C"
|
|
||||||
// + _bbox[1] + "%2C" + _bbox[2] + "%2C" + _bbox[3] + "&X=" + x + "&Y=" + y
|
|
||||||
// + "&INFO_FORMAT=text%2Fhtml&QUERY_LAYERS=" + strListLayers + "&FEATURE_COUNT=50&Layers=" + strListLayers
|
|
||||||
// + "&Styles=&Srs=" + projection + "&WIDTH=" + width + "&HEIGHT=" + height + "&format=image%2Fpng";
|
|
||||||
//
|
|
||||||
// return result;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//// public static String getURLFeatureInfo(ClickDataInfo clickDataInfo, String projection, String bbox) {
|
|
||||||
//// return getURL(projection, clickDataInfo.getW(), clickDataInfo.getH(), clickDataInfo.getX(), clickDataInfo.getY(), bbox, clickDataInfo.getLayers());
|
|
||||||
//// }
|
|
||||||
|
|
||||||
// /**
|
|
||||||
// * Gets the url.
|
|
||||||
// *
|
|
||||||
// * @param clickDataInfo the click data info
|
|
||||||
// * @param projection the projection
|
|
||||||
// * @param layerItems the layer items
|
|
||||||
// * @return the url
|
|
||||||
// */
|
|
||||||
// public static String getURL(ClickDataInfo clickDataInfo, String projection, List<LayerItem> layerItems) {
|
|
||||||
// return getURL(projection, clickDataInfo.getW(), clickDataInfo.getH(), clickDataInfo.getX(),
|
|
||||||
// clickDataInfo.getY(), clickDataInfo.getBbox(), layerItems);
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the wfs feature url.
|
|
||||||
*
|
|
||||||
* @param l the l
|
|
||||||
* @param bbox the bbox
|
|
||||||
* @param limit the limit
|
|
||||||
* @param format the format
|
|
||||||
* @return the wfs feature url
|
|
||||||
*/
|
|
||||||
public static String getWfsFeatureUrl(LayerItem l, String srsName, String bbox, int limit, String format) {
|
|
||||||
|
|
||||||
String link = l.getUrl();
|
|
||||||
GWT.log("Layer URL: " + link);
|
|
||||||
GWT.log("CQL filter is: " + l.getCqlFilter());
|
|
||||||
|
|
||||||
String outputformat = null;
|
|
||||||
String boundingBox = bbox;
|
|
||||||
|
|
||||||
// CASE MAP SERVER
|
|
||||||
SERVERTYPE mapserverType = MapServerRecognize.recongnize(l);
|
|
||||||
GWT.log("Recongnized SERVERTYPE: " + mapserverType);
|
|
||||||
|
|
||||||
if (mapserverType != null) {
|
|
||||||
if (mapserverType.equals(SERVERTYPE.MAPSERVER)) {
|
|
||||||
GWT.log("wms url contains wxs is a map server? no appending /wfs ");
|
|
||||||
outputformat = MapServerRecognize.outputFormatRecognize(SERVERTYPE.MAPSERVER, format);
|
|
||||||
srsName = "EPSG:4326";
|
|
||||||
boundingBox = reverseCoordinate(bbox, ","); // USE AXIS XY
|
|
||||||
// TODO DEBUG
|
|
||||||
GWT.log("SERVERTYPE.MAPSERVER outputformat: " + outputformat);
|
|
||||||
GWT.log("SERVERTYPE.MAPSERVER srsName: " + srsName);
|
|
||||||
GWT.log("SERVERTYPE.MAPSERVER boundingBox: " + boundingBox);
|
|
||||||
} else {
|
|
||||||
GWT.log("is geoserver appending suffix /wfs if is not present");
|
|
||||||
link += link.endsWith("wfs") ? "" : "/wfs";
|
|
||||||
outputformat = MapServerRecognize.outputFormatRecognize(SERVERTYPE.GEOSEVER, format);
|
|
||||||
srsName = "urn:x-ogc:def:crs:"+srsName; // USE AXIS YX
|
|
||||||
// TODO DEBUG
|
|
||||||
GWT.log("SERVERTYPE.GEOSEVER outputformat: " + outputformat);
|
|
||||||
GWT.log("SERVERTYPE.GEOSEVER srsName: " + srsName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
link += "?service=wfs&version=1.1.0" + "&REQUEST=GetFeature" + "&srsName=" + srsName + "&TYPENAME="
|
|
||||||
+ l.getName() + (limit == 0 ? "" : "&MAXFEATURES=" + limit)
|
|
||||||
+ (outputformat == null ? "" : "&OUTPUTFORMAT=" + outputformat);
|
|
||||||
|
|
||||||
if (l.getCqlFilter() != null && !l.getCqlFilter().isEmpty()) {
|
|
||||||
if (l.getCqlFilter().contains("BBOX(the_geom")) {
|
|
||||||
// THE BBOX IS ALREADY USED INTO CQL FILTERING, SO USING IT DIRECTLY
|
|
||||||
link += "&" + CQL_FILTER_PARAMETER + "=" + l.getCqlFilter();
|
|
||||||
} else {
|
|
||||||
// I NEED TO ENCODE THE BBOX INTO CQL FILTERING,
|
|
||||||
String cqlFilterValue = "BBOX(the_geom," + boundingBox + ")" + " AND " + l.getCqlFilter();
|
|
||||||
|
|
||||||
link += "&" + CQL_FILTER_PARAMETER + "=" + cqlFilterValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// NO CQL FILTERING APPLIED
|
|
||||||
link += (boundingBox == null ? "" : "&BBOX=" + boundingBox);
|
|
||||||
}
|
|
||||||
|
|
||||||
GWT.log("WFS: " + link);
|
|
||||||
return link;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reverse coordinate.
|
|
||||||
*
|
|
||||||
* @param BBOX the bbox
|
|
||||||
* @param split eg. ,
|
|
||||||
* @return a BBOX with reverse x and y coordinate
|
|
||||||
*/
|
|
||||||
public static String reverseCoordinate(String BBOX, String split) {
|
|
||||||
|
|
||||||
if (BBOX == null || BBOX.isEmpty()) {
|
|
||||||
return BBOX;
|
|
||||||
}
|
|
||||||
|
|
||||||
String[] splitted = BBOX.split(split);
|
|
||||||
|
|
||||||
for (String string : splitted) {
|
|
||||||
System.out.println(string);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (splitted.length == 4) {
|
|
||||||
return splitted[1] + split + splitted[0] + split + splitted[3] + split + splitted[2];
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Encode url.
|
|
||||||
*
|
|
||||||
* @param url the url
|
|
||||||
* @return the string
|
|
||||||
*/
|
|
||||||
public static String encodeUrl(String url) {
|
|
||||||
String urlNew = url;
|
|
||||||
for (String[] s : a) {
|
|
||||||
urlNew = urlNew.replaceAll(s[0], s[1]);
|
|
||||||
}
|
|
||||||
return urlNew;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Decode url.
|
|
||||||
*
|
|
||||||
* @param url the url
|
|
||||||
* @return the string
|
|
||||||
*/
|
|
||||||
public static String decodeUrl(String url) {
|
|
||||||
String urlNew = url;
|
|
||||||
for (String[] s : a) {
|
|
||||||
urlNew = urlNew.replaceAll(s[1], s[0]);
|
|
||||||
}
|
|
||||||
return urlNew;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes the last char.
|
|
||||||
*
|
|
||||||
* @param string the string
|
|
||||||
* @return the string
|
|
||||||
*/
|
|
||||||
public static String removeLastChar(String string) {
|
|
||||||
|
|
||||||
if (string == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
if (string.length() > 0)
|
|
||||||
return string.substring(0, string.length() - 1);
|
|
||||||
|
|
||||||
return string;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,5 +1,12 @@
|
||||||
package org.gcube.portlets.user.geoportaldataviewer.client.util;
|
package org.gcube.portlets.user.geoportaldataviewer.client.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class URLUtil.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
*
|
||||||
|
* Oct 29, 2020
|
||||||
|
*/
|
||||||
public class URLUtil {
|
public class URLUtil {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,4 +34,55 @@ public class URLUtil {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the parameter to query string.
|
||||||
|
*
|
||||||
|
* @param key the key
|
||||||
|
* @param value the value
|
||||||
|
* @param prefixAmpersand the prefix ampersand
|
||||||
|
* @param suffixAmpersand the suffix ampersand
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
|
public static String addParameterToQueryString(String key, String value, boolean prefixAmpersand, boolean suffixAmpersand) {
|
||||||
|
|
||||||
|
String queryParameter = "";
|
||||||
|
|
||||||
|
if(prefixAmpersand)
|
||||||
|
queryParameter+="&";
|
||||||
|
|
||||||
|
queryParameter+=key+"="+value;
|
||||||
|
|
||||||
|
if(suffixAmpersand)
|
||||||
|
queryParameter+="&";
|
||||||
|
|
||||||
|
return queryParameter;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract value of parameter from URL.
|
||||||
|
*
|
||||||
|
* @param paramName the param name
|
||||||
|
* @param url the url
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
|
public static String extractValueOfParameterFromURL(String paramName, String url) {
|
||||||
|
int index = url.toLowerCase().indexOf(paramName.toLowerCase() + "="); // ADDING CHAR "=" IN TAIL TO BE SURE THAT IT
|
||||||
|
// IS A PARAMETER
|
||||||
|
String value = "";
|
||||||
|
if (index > -1) {
|
||||||
|
|
||||||
|
int start = index + paramName.length() + 1; // add +1 for char '='
|
||||||
|
String sub = url.substring(start, url.length());
|
||||||
|
int indexOfSeparator = sub.indexOf("&");
|
||||||
|
int end = indexOfSeparator != -1 ? indexOfSeparator : sub.length();
|
||||||
|
value = sub.substring(0, end);
|
||||||
|
} else
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
package org.gcube.portlets.user.geoportaldataviewer.server;
|
package org.gcube.portlets.user.geoportaldataviewer.server;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerService;
|
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerService;
|
||||||
|
import org.gcube.portlets.user.geoportaldataviewer.server.gis.FeatureParser;
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.server.gis.WMSUrlValidator;
|
import org.gcube.portlets.user.geoportaldataviewer.server.gis.WMSUrlValidator;
|
||||||
|
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataObject;
|
||||||
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap;
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoInformationForWMSRequest;
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.GeoInformationForWMSRequest;
|
||||||
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.Styles;
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.Styles;
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.ZAxis;
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.ZAxis;
|
||||||
import org.gcube.spatial.data.geoutility.GeoNcWMSMetadataUtility;
|
import org.gcube.spatial.data.geoutility.GeoNcWMSMetadataUtility;
|
||||||
|
@ -74,4 +79,15 @@ public class GeoportalDataViewerServiceImpl extends RemoteServiceServlet impleme
|
||||||
throw new Exception(msg);
|
throw new Exception(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.gcube.portlets.user.gisviewer.client.GisViewerService#getDataResult(java.util.List, java.lang.String, int)
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<GeoNaDataObject> getDataResult(List<LayerItem> layerItems, String mapSrsName, BoundsMap mapBBOX, int maxWFSFeature, double zoomLevel) {
|
||||||
|
LOG.info("getDataResult called");
|
||||||
|
List<GeoNaDataObject> result = FeatureParser.getDataResults(layerItems, mapSrsName, mapBBOX, maxWFSFeature);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,151 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.geoportaldataviewer.server.gis;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.commons.io.IOUtils;
|
||||||
|
import org.gcube.portlets.user.geoportaldataviewer.client.GeoportalDataViewerConstants;
|
||||||
|
import org.gcube.portlets.user.geoportaldataviewer.server.util.URLParserUtil;
|
||||||
|
import org.gcube.portlets.user.geoportaldataviewer.shared.FeatureRow;
|
||||||
|
import org.gcube.portlets.user.geoportaldataviewer.shared.GeoNaDataObject;
|
||||||
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.BoundsMap;
|
||||||
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONException;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class FeatureParser.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
*
|
||||||
|
* Oct 29, 2020
|
||||||
|
*/
|
||||||
|
public class FeatureParser {
|
||||||
|
|
||||||
|
private static Logger LOG = LoggerFactory.getLogger(FeatureParser.class);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the data results.
|
||||||
|
*
|
||||||
|
* @param layerItems the layer items
|
||||||
|
* @param mapSrsName the map srs name
|
||||||
|
* @param mapBBOX the map BBOX
|
||||||
|
* @param maxWFSFeature the max WFS feature
|
||||||
|
* @return the data results
|
||||||
|
*/
|
||||||
|
public static List<GeoNaDataObject> getDataResults(List<LayerItem> layerItems, String mapSrsName, BoundsMap mapBBOX, int maxWFSFeature) {
|
||||||
|
|
||||||
|
if(maxWFSFeature<0) {
|
||||||
|
maxWFSFeature = GeoportalDataViewerConstants.MAX_WFS_FEATURES;
|
||||||
|
}
|
||||||
|
|
||||||
|
//IF WFS IS AVAILABLE USE WFS REQUEST OTHERWHISE TRY TO USE WPS SERVICE
|
||||||
|
for (LayerItem layerItem : layerItems){
|
||||||
|
List<FeatureRow> rows = getWFSFeatureProperties(layerItem, mapSrsName, mapBBOX, maxWFSFeature);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the WFS feature properties.
|
||||||
|
*
|
||||||
|
* @param layerItem the layer item
|
||||||
|
* @param mapSrsName the map srs name
|
||||||
|
* @param mapBBOX the map BBOX
|
||||||
|
* @param maxWFSFeature the max WFS feature
|
||||||
|
* @return the WFS feature properties
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private static List<FeatureRow> getWFSFeatureProperties(LayerItem layerItem, String mapSrsName, BoundsMap mapBBOX, int maxWFSFeature) {
|
||||||
|
|
||||||
|
LOG.info("getTableFromJson -> Creating WfsTable to layerItem: "+layerItem.getName());
|
||||||
|
InputStream is = null;
|
||||||
|
List<FeatureRow> listFeaturesRow = new ArrayList<FeatureRow>();
|
||||||
|
try {
|
||||||
|
String url = GisMakers.buildWFSFeatureQuery(layerItem, mapSrsName, mapBBOX, maxWFSFeature, GisMakers.JSON);
|
||||||
|
String cqlFilterValue = URLParserUtil.extractValueOfParameterFromURL(GisMakers.CQL_FILTER_PARAMETER, url);
|
||||||
|
LOG.info("Found CQL filter value into query string: "+cqlFilterValue);
|
||||||
|
|
||||||
|
if(cqlFilterValue!=null) {
|
||||||
|
String notEncodedCQLFilter = String.format("%s=%s",GisMakers.CQL_FILTER_PARAMETER,cqlFilterValue);
|
||||||
|
//log.info("Found CQL filter: "+notEncodedCQLFilter);
|
||||||
|
String toEncodeCQLFilter = String.format("%s=%s",GisMakers.CQL_FILTER_PARAMETER,URLEncoder.encode(cqlFilterValue,"UTF-8"));
|
||||||
|
LOG.debug("Encoded CQL filter: "+toEncodeCQLFilter);
|
||||||
|
url = url.replace(notEncodedCQLFilter, toEncodeCQLFilter);
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG.info("getTableFromJson -> WFS URL: "+url);
|
||||||
|
is = new URL(url).openStream();
|
||||||
|
String jsonTxt = IOUtils.toString(is);
|
||||||
|
|
||||||
|
if(jsonTxt==null || jsonTxt.isEmpty()){
|
||||||
|
jsonTxt = "{\"type\":\"FeatureCollection\",\"features\":[]}";
|
||||||
|
}
|
||||||
|
|
||||||
|
// get json object
|
||||||
|
JSONObject json = new JSONObject(jsonTxt);
|
||||||
|
// iterate features
|
||||||
|
JSONArray features = json.getJSONArray("features");
|
||||||
|
if(features.length()==0) {
|
||||||
|
LOG.info("No features detected in the response, returning empty list");
|
||||||
|
return listFeaturesRow;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i=0; i<features.length(); i++) {
|
||||||
|
final FeatureRow row = new FeatureRow();
|
||||||
|
JSONObject theFeature = ((JSONObject)features.get(i));
|
||||||
|
LOG.debug("Building at index: "+i);
|
||||||
|
// // iterate properties
|
||||||
|
JSONObject properties = theFeature.getJSONObject("properties");
|
||||||
|
Map<String,List<String>> mapProperties = new HashMap<String,List<String>>();
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
Iterator<String> ii = properties.keys();
|
||||||
|
while (ii.hasNext()) {
|
||||||
|
String key = ii.next();
|
||||||
|
String value = properties.optString(key,"");
|
||||||
|
|
||||||
|
List<String> theValues = mapProperties.get(key);
|
||||||
|
if(theValues==null)
|
||||||
|
mapProperties.put(key, Arrays.asList(value));
|
||||||
|
else {
|
||||||
|
theValues.add(value);
|
||||||
|
mapProperties.put(key, theValues);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
row.setMapProperties(mapProperties);
|
||||||
|
listFeaturesRow.add(row);
|
||||||
|
|
||||||
|
LOG.info("Added row "+row+" to exported properties");
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
LOG.error("Error for layerItem name: "+layerItem.getName(), e);
|
||||||
|
} catch (JSONException e) {
|
||||||
|
LOG.error("Error for layerItem name: "+layerItem.getName(), e);
|
||||||
|
}finally{
|
||||||
|
IOUtils.closeQuietly(is);
|
||||||
|
}
|
||||||
|
|
||||||
|
return listFeaturesRow;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,213 @@
|
||||||
|
package org.gcube.portlets.user.geoportaldataviewer.server.gis;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.geoportaldataviewer.server.gis.MapServerRecognize.SERVERTYPE;
|
||||||
|
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 com.google.gwt.core.shared.GWT;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class URLMakers.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
*
|
||||||
|
* Oct 29, 2020
|
||||||
|
*/
|
||||||
|
public class GisMakers {
|
||||||
|
|
||||||
|
public static final String CQL_FILTER_PARAMETER = "CQL_FILTER";
|
||||||
|
|
||||||
|
// MAP SERVER PIVOT
|
||||||
|
public static final String WXS = "wxs";
|
||||||
|
// GEOSERVER PIVOT
|
||||||
|
public static final String WMS = "/wms";
|
||||||
|
|
||||||
|
// OUTPUT FORMAT
|
||||||
|
public static final String CSV = "csv";
|
||||||
|
|
||||||
|
public static final String JSON = "json";
|
||||||
|
|
||||||
|
private static String[][] a = { { "\\?", "%3F" }, { "&", "%26" }, };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Enum COORDINATE_FORMAT.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
*
|
||||||
|
* Oct 29, 2020
|
||||||
|
*/
|
||||||
|
public static enum COORDINATE_FORMAT {
|
||||||
|
XY, YX
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds the WFS feature query.
|
||||||
|
*
|
||||||
|
* @param layerItem the layer item
|
||||||
|
* @param mapSrsName the map srs name
|
||||||
|
* @param mapBBOX the map BBOX
|
||||||
|
* @param maxFeatures the max features
|
||||||
|
* @param outputFormat the output format
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
|
public static String buildWFSFeatureQuery(LayerItem layerItem, String mapSrsName, BoundsMap mapBBOX, int maxFeatures, String outputFormat) {
|
||||||
|
|
||||||
|
String link = layerItem.getMapServerHost();
|
||||||
|
GWT.log("Map server host URL: " + link);
|
||||||
|
GWT.log("CQL filter is: " + layerItem.getCqlFilter());
|
||||||
|
|
||||||
|
String outputformat = null;
|
||||||
|
String boundingBox = "";
|
||||||
|
|
||||||
|
// CASE MAP SERVER
|
||||||
|
SERVERTYPE mapserverType = MapServerRecognize.recongnize(layerItem);
|
||||||
|
GWT.log("Recongnized SERVERTYPE: " + mapserverType);
|
||||||
|
|
||||||
|
if (mapserverType != null) {
|
||||||
|
if (mapserverType.equals(SERVERTYPE.MAPSERVER)) {
|
||||||
|
GWT.log("wms url contains wxs is a map server? no appending /wfs ");
|
||||||
|
outputformat = MapServerRecognize.outputFormatRecognize(SERVERTYPE.MAPSERVER, outputFormat);
|
||||||
|
mapSrsName = "EPSG:4326";
|
||||||
|
boundingBox = BBOX_FORMAT(COORDINATE_FORMAT.XY, ",",mapBBOX.getLowerLeftX(),mapBBOX.getLowerLeftY(),mapBBOX.getUpperRightX(),mapBBOX.getUpperRightY()); // USE AXIS XY
|
||||||
|
// TODO DEBUG
|
||||||
|
GWT.log("SERVERTYPE.MAPSERVER outputformat: " + outputformat);
|
||||||
|
GWT.log("SERVERTYPE.MAPSERVER srsName: " + mapSrsName);
|
||||||
|
GWT.log("SERVERTYPE.MAPSERVER boundingBox: " + boundingBox);
|
||||||
|
} else {
|
||||||
|
GWT.log("is geoserver appending suffix /wfs if is not present");
|
||||||
|
link += link.endsWith("wfs") ? "" : "/wfs";
|
||||||
|
outputformat = MapServerRecognize.outputFormatRecognize(SERVERTYPE.GEOSEVER, outputFormat);
|
||||||
|
mapSrsName = "urn:x-ogc:def:crs:"+mapSrsName; // USE AXIS YX
|
||||||
|
boundingBox = BBOX_FORMAT(COORDINATE_FORMAT.YX, ",",mapBBOX.getLowerLeftX(),mapBBOX.getLowerLeftY(),mapBBOX.getUpperRightX(),mapBBOX.getUpperRightY()); // USE AXIS XY
|
||||||
|
// TODO DEBUG
|
||||||
|
GWT.log("SERVERTYPE.GEOSEVER outputformat: " + outputformat);
|
||||||
|
GWT.log("SERVERTYPE.GEOSEVER srsName: " + mapSrsName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//
|
||||||
|
// link += "?service=wfs&version=1.1.0" + "&REQUEST=GetFeature" + "&srsName=" + srsName + "&TYPENAME="
|
||||||
|
// + layerItem.getName() + (limit == 0 ? "" : "&MAXFEATURES=" + limit)
|
||||||
|
// + (outputformat == null ? "" : "&OUTPUTFORMAT=" + outputformat);
|
||||||
|
//
|
||||||
|
|
||||||
|
link += "?"+
|
||||||
|
URLParserUtil.addParameterToQueryString(WFSGetFeature.SERVICE.getParameter(), WFSGetFeature.SERVICE.getValue(), false, true)+
|
||||||
|
URLParserUtil.addParameterToQueryString(WFSGetFeature.VERSION.getParameter(), WFSGetFeature.VERSION.getValue(), false, true)+
|
||||||
|
URLParserUtil.addParameterToQueryString(WFSGetFeature.REQUEST.getParameter(), WFSGetFeature.REQUEST.getValue(), false, true)+
|
||||||
|
URLParserUtil.addParameterToQueryString(WFSGetFeature.SRSNAME.getParameter(), mapSrsName, false, true)+
|
||||||
|
URLParserUtil.addParameterToQueryString(WFSGetFeature.TYPENAME.getParameter(), layerItem.getName(), false, true)+
|
||||||
|
(maxFeatures == 0 ? "" : URLParserUtil.addParameterToQueryString(WFSGetFeature.MAXFEATURES.getParameter(), maxFeatures+"", false, true))+
|
||||||
|
(outputformat == null ? "" : URLParserUtil.addParameterToQueryString(WFSGetFeature.OUTPUTFORMAT.getParameter(), outputformat, false, false));
|
||||||
|
|
||||||
|
|
||||||
|
if (layerItem.getCqlFilter() != null && !layerItem.getCqlFilter().isEmpty()) {
|
||||||
|
if (layerItem.getCqlFilter().contains("BBOX(the_geom")) {
|
||||||
|
// THE BBOX IS ALREADY USED INTO CQL FILTERING, SO USING IT DIRECTLY
|
||||||
|
link += "&" + CQL_FILTER_PARAMETER + "=" + layerItem.getCqlFilter();
|
||||||
|
} else {
|
||||||
|
// I NEED TO ENCODE THE BBOX INTO CQL FILTERING,
|
||||||
|
String cqlFilterValue = "BBOX(the_geom," + boundingBox + ")" + " AND " + layerItem.getCqlFilter();
|
||||||
|
|
||||||
|
link += "&" + CQL_FILTER_PARAMETER + "=" + cqlFilterValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// NO CQL FILTERING APPLIED
|
||||||
|
link += (boundingBox == null ? "" : "&BBOX=" + boundingBox);
|
||||||
|
}
|
||||||
|
|
||||||
|
GWT.log("WFS: " + link);
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encode url.
|
||||||
|
*
|
||||||
|
* @param url the url
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
|
public static String encodeUrl(String url) {
|
||||||
|
String urlNew = url;
|
||||||
|
for (String[] s : a) {
|
||||||
|
urlNew = urlNew.replaceAll(s[0], s[1]);
|
||||||
|
}
|
||||||
|
return urlNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decode url.
|
||||||
|
*
|
||||||
|
* @param url the url
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
|
public static String decodeUrl(String url) {
|
||||||
|
String urlNew = url;
|
||||||
|
for (String[] s : a) {
|
||||||
|
urlNew = urlNew.replaceAll(s[1], s[0]);
|
||||||
|
}
|
||||||
|
return urlNew;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes the last char.
|
||||||
|
*
|
||||||
|
* @param string the string
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
|
public static String removeLastChar(String string) {
|
||||||
|
|
||||||
|
if (string == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
if (string.length() > 0)
|
||||||
|
return string.substring(0, string.length() - 1);
|
||||||
|
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format.
|
||||||
|
*
|
||||||
|
* @param format the format
|
||||||
|
* @param separator the separator
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
|
public static String BBOX_FORMAT(COORDINATE_FORMAT format, String separator, double lowerLeftX, double lowerLeftY, double upperRightX, double upperRightY) {
|
||||||
|
|
||||||
|
if(format==null)
|
||||||
|
format = COORDINATE_FORMAT.XY;
|
||||||
|
|
||||||
|
if(separator==null)
|
||||||
|
separator = ",";
|
||||||
|
|
||||||
|
switch (format) {
|
||||||
|
case XY:
|
||||||
|
return String.format("%s%s%s%s%s%s%s",
|
||||||
|
String.valueOf(lowerLeftX),
|
||||||
|
separator,
|
||||||
|
String.valueOf(lowerLeftY),
|
||||||
|
separator,
|
||||||
|
String.valueOf(upperRightX),
|
||||||
|
separator,
|
||||||
|
String.valueOf(upperRightY)
|
||||||
|
);
|
||||||
|
case YX:
|
||||||
|
return String.format("%s%s%s%s%s%s%s",
|
||||||
|
String.valueOf(lowerLeftY),
|
||||||
|
separator,
|
||||||
|
String.valueOf(lowerLeftX),
|
||||||
|
separator,
|
||||||
|
String.valueOf(upperRightY),
|
||||||
|
separator,
|
||||||
|
String.valueOf(upperRightX)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,23 +1,38 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.gcube.portlets.user.geoportaldataviewer.client.util;
|
package org.gcube.portlets.user.geoportaldataviewer.server.gis;
|
||||||
|
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
|
||||||
|
|
||||||
import com.google.gwt.core.shared.GWT;
|
import com.google.gwt.core.shared.GWT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* The Class MapServerRecognize.
|
||||||
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
* @Aug 29, 2014
|
* @Aug 29, 2014
|
||||||
*
|
*
|
||||||
*THIS CLASS DISCRIMINATES BETWEEN GEOSERVER AND MAPSERVER
|
* THIS CLASS DISCRIMINATES BETWEEN GEOSERVER AND MAPSERVER
|
||||||
*ACCORDING TO THE VALUE OF LAYER URL
|
* ACCORDING TO THE VALUE OF LAYER URL
|
||||||
*/
|
*/
|
||||||
public class MapServerRecognize {
|
public class MapServerRecognize {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Enum SERVERTYPE.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
*
|
||||||
|
* Oct 29, 2020
|
||||||
|
*/
|
||||||
public static enum SERVERTYPE{GEOSEVER, MAPSERVER};
|
public static enum SERVERTYPE{GEOSEVER, MAPSERVER};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recongnize.
|
||||||
|
*
|
||||||
|
* @param l the l
|
||||||
|
* @return the servertype
|
||||||
|
*/
|
||||||
public static SERVERTYPE recongnize(LayerItem l){
|
public static SERVERTYPE recongnize(LayerItem l){
|
||||||
|
|
||||||
if(l==null)
|
if(l==null)
|
||||||
|
@ -26,13 +41,19 @@ public class MapServerRecognize {
|
||||||
return recongnize(l.getUrl());
|
return recongnize(l.getUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recongnize.
|
||||||
|
*
|
||||||
|
* @param baseServerUrl the base server url
|
||||||
|
* @return the servertype
|
||||||
|
*/
|
||||||
public static SERVERTYPE recongnize(String baseServerUrl){
|
public static SERVERTYPE recongnize(String baseServerUrl){
|
||||||
|
|
||||||
if(baseServerUrl==null || baseServerUrl.isEmpty())
|
if(baseServerUrl==null || baseServerUrl.isEmpty())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
//CASE MAP SERVER
|
//CASE MAP SERVER
|
||||||
if(baseServerUrl.contains(URLMakers.WXS)){
|
if(baseServerUrl.contains(GisMakers.WXS)){
|
||||||
GWT.log("wms url contains 'wxs' returning "+SERVERTYPE.MAPSERVER);
|
GWT.log("wms url contains 'wxs' returning "+SERVERTYPE.MAPSERVER);
|
||||||
return SERVERTYPE.MAPSERVER;
|
return SERVERTYPE.MAPSERVER;
|
||||||
}else{
|
}else{
|
||||||
|
@ -43,10 +64,11 @@ public class MapServerRecognize {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Output format recognize.
|
||||||
*
|
*
|
||||||
* @param serverType
|
* @param serverType the server type
|
||||||
* @param output
|
* @param output the output
|
||||||
* @return
|
* @return the string
|
||||||
*/
|
*/
|
||||||
public static String outputFormatRecognize(SERVERTYPE serverType, String output){
|
public static String outputFormatRecognize(SERVERTYPE serverType, String output){
|
||||||
|
|
||||||
|
@ -59,17 +81,17 @@ public class MapServerRecognize {
|
||||||
switch (serverType) {
|
switch (serverType) {
|
||||||
|
|
||||||
case GEOSEVER:
|
case GEOSEVER:
|
||||||
if(output.contains(URLMakers.JSON))
|
if(output.contains(GisMakers.JSON))
|
||||||
return "json";
|
return "json";
|
||||||
else if(output.contains(URLMakers.CSV))
|
else if(output.contains(GisMakers.CSV))
|
||||||
return "csv";
|
return "csv";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MAPSERVER:
|
case MAPSERVER:
|
||||||
|
|
||||||
if(output.contains(URLMakers.JSON))
|
if(output.contains(GisMakers.JSON))
|
||||||
return "application/json;%20subtype=geojson";
|
return "application/json;%20subtype=geojson";
|
||||||
else if(output.contains(URLMakers.CSV))
|
else if(output.contains(GisMakers.CSV))
|
||||||
return "csv";
|
return "csv";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
|
@ -0,0 +1,77 @@
|
||||||
|
package org.gcube.portlets.user.geoportaldataviewer.server.gis;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Enum WfsParameters.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
*
|
||||||
|
* Oct 29, 2020
|
||||||
|
*/
|
||||||
|
public enum WFSGetFeature {
|
||||||
|
|
||||||
|
SERVICE("SERVICE", "WFS"),
|
||||||
|
VERSION("VERSION", "1.1.0"),
|
||||||
|
REQUEST("REQUEST", "GetFeature"),
|
||||||
|
TYPENAME("TYPENAME", ""),
|
||||||
|
STYLES("STYLES",""),
|
||||||
|
BBOX("BBOX","-180,-90,180,90"),
|
||||||
|
WIDTH("WIDTH","676"),
|
||||||
|
HEIGHT("HEIGHT","230"),
|
||||||
|
SRSNAME("srsName","EPSG:4326"),
|
||||||
|
// CRS("CRS","EPSG:4326"), //WMS 1.3.0 COMPLIANT
|
||||||
|
OUTPUTFORMAT("OUTPUTFORMAT","json"),
|
||||||
|
MAXFEATURES("MAXFEATURES","");
|
||||||
|
|
||||||
|
private String parameter;
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new wfs parameters.
|
||||||
|
*
|
||||||
|
* @param parameter the parameter
|
||||||
|
* @param value the value
|
||||||
|
*/
|
||||||
|
WFSGetFeature(String parameter, String value){
|
||||||
|
this.parameter = parameter;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the parameter.
|
||||||
|
*
|
||||||
|
* @return the parameter
|
||||||
|
*/
|
||||||
|
public String getParameter() {
|
||||||
|
return parameter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the parameter.
|
||||||
|
*
|
||||||
|
* @param parameter the new parameter
|
||||||
|
*/
|
||||||
|
public void setParameter(String parameter) {
|
||||||
|
this.parameter = parameter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value.
|
||||||
|
*
|
||||||
|
* @return the value
|
||||||
|
*/
|
||||||
|
public String getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value.
|
||||||
|
*
|
||||||
|
* @param value the new value
|
||||||
|
*/
|
||||||
|
public void setValue(String value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,88 @@
|
||||||
|
package org.gcube.portlets.user.geoportaldataviewer.server.util;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class URLUtil.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
*
|
||||||
|
* Oct 29, 2020
|
||||||
|
*/
|
||||||
|
public class URLParserUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of parameter.
|
||||||
|
*
|
||||||
|
* @param paramName the param name
|
||||||
|
* @param url the url
|
||||||
|
* @return the value of parameter
|
||||||
|
*/
|
||||||
|
public static String getValueOfParameter(String paramName, String url) {
|
||||||
|
// logger.trace("finding: "+wmsParam +" into "+url);
|
||||||
|
int index = url.toLowerCase().indexOf(paramName.toLowerCase()+"="); //ADDING CHAR "=" IN TAIL TO BE SECURE IT IS A PARAMETER
|
||||||
|
// logger.trace("start index of "+wmsParam+ " is: "+index);
|
||||||
|
String value = "";
|
||||||
|
if(index > -1){
|
||||||
|
int start = index + paramName.length()+1; //add +1 for char '='
|
||||||
|
String sub = url.substring(start, url.length());
|
||||||
|
int indexOfSeparator = sub.indexOf("&");
|
||||||
|
int end = indexOfSeparator!=-1?indexOfSeparator:sub.length();
|
||||||
|
value = sub.substring(0, end);
|
||||||
|
}else
|
||||||
|
return null;
|
||||||
|
|
||||||
|
// logger.trace("return value: "+value);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the parameter to query string.
|
||||||
|
*
|
||||||
|
* @param key the key
|
||||||
|
* @param value the value
|
||||||
|
* @param prefixAmpersand the prefix ampersand
|
||||||
|
* @param suffixAmpersand the suffix ampersand
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
|
public static String addParameterToQueryString(String key, String value, boolean prefixAmpersand, boolean suffixAmpersand) {
|
||||||
|
|
||||||
|
String queryParameter = "";
|
||||||
|
|
||||||
|
if(prefixAmpersand)
|
||||||
|
queryParameter+="&";
|
||||||
|
|
||||||
|
queryParameter+=key+"="+value;
|
||||||
|
|
||||||
|
if(suffixAmpersand)
|
||||||
|
queryParameter+="&";
|
||||||
|
|
||||||
|
return queryParameter;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extract value of parameter from URL.
|
||||||
|
*
|
||||||
|
* @param paramName the param name
|
||||||
|
* @param url the url
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
|
public static String extractValueOfParameterFromURL(String paramName, String url) {
|
||||||
|
int index = url.toLowerCase().indexOf(paramName.toLowerCase() + "="); // ADDING CHAR "=" IN TAIL TO BE SURE THAT IT
|
||||||
|
// IS A PARAMETER
|
||||||
|
String value = "";
|
||||||
|
if (index > -1) {
|
||||||
|
|
||||||
|
int start = index + paramName.length() + 1; // add +1 for char '='
|
||||||
|
String sub = url.substring(start, url.length());
|
||||||
|
int indexOfSeparator = sub.indexOf("&");
|
||||||
|
int end = indexOfSeparator != -1 ? indexOfSeparator : sub.length();
|
||||||
|
value = sub.substring(0, end);
|
||||||
|
} else
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
package org.gcube.portlets.user.geoportaldataviewer.shared;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class FeatureRow.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
*
|
||||||
|
* Oct 29, 2020
|
||||||
|
*/
|
||||||
|
public class FeatureRow implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 6254861811998867626L;
|
||||||
|
|
||||||
|
private Map<String, List<String>> mapProperties;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public Map<String, List<String>> getMapProperties() {
|
||||||
|
return mapProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void setMapProperties(Map<String, List<String>> mapProperties) {
|
||||||
|
this.mapProperties = mapProperties;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.lang.Object#toString()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("FeatureRow [mapValues=");
|
||||||
|
builder.append(mapProperties);
|
||||||
|
builder.append("]");
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,82 @@
|
||||||
|
package org.gcube.portlets.user.geoportaldataviewer.shared;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class GeoNaDataObject.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
*
|
||||||
|
* Oct 29, 2020
|
||||||
|
*/
|
||||||
|
public class GeoNaDataObject implements Serializable{
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 5566069859060851625L;
|
||||||
|
/** The form data entry fields. */
|
||||||
|
private Map<String, List<String>> dataEntryFields;
|
||||||
|
private String geonaDataType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new geo na data object.
|
||||||
|
*/
|
||||||
|
public GeoNaDataObject(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the data entry fields.
|
||||||
|
*
|
||||||
|
* @return the data entry fields
|
||||||
|
*/
|
||||||
|
public Map<String, List<String>> getDataEntryFields() {
|
||||||
|
return dataEntryFields;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the data entry fields.
|
||||||
|
*
|
||||||
|
* @param dataEntryFields the data entry fields
|
||||||
|
*/
|
||||||
|
public void setDataEntryFields(Map<String, List<String>> dataEntryFields) {
|
||||||
|
this.dataEntryFields = dataEntryFields;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the geona data type.
|
||||||
|
*
|
||||||
|
* @return the geona data type
|
||||||
|
*/
|
||||||
|
public String getGeonaDataType() {
|
||||||
|
return geonaDataType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the geona data type.
|
||||||
|
*
|
||||||
|
* @param geonaDataType the new geona data type
|
||||||
|
*/
|
||||||
|
public void setGeonaDataType(String geonaDataType) {
|
||||||
|
this.geonaDataType = geonaDataType;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see java.lang.Object#toString()
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("GeoNaFormDataObject [dataEntryFields=");
|
||||||
|
builder.append(dataEntryFields);
|
||||||
|
builder.append(", geonaDataType=");
|
||||||
|
builder.append(geonaDataType);
|
||||||
|
builder.append("]");
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -11,6 +11,7 @@ import java.io.Serializable;
|
||||||
*/
|
*/
|
||||||
public class BoundsMap implements Serializable{
|
public class BoundsMap implements Serializable{
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -31,6 +32,8 @@ public class BoundsMap implements Serializable{
|
||||||
/** The crs. */
|
/** The crs. */
|
||||||
private String crs = "";
|
private String crs = "";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new bounds map.
|
* Instantiates a new bounds map.
|
||||||
*/
|
*/
|
||||||
|
@ -148,8 +151,19 @@ public class BoundsMap implements Serializable{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "BoundsMap [lowerLeftX=" + lowerLeftX + ", lowerLeftY=" + lowerLeftY + ", upperRightX=" + upperRightX
|
StringBuilder builder = new StringBuilder();
|
||||||
+ ", upperRightY=" + upperRightY + ", crs=" + crs + "]";
|
builder.append("BoundsMap [lowerLeftX=");
|
||||||
|
builder.append(lowerLeftX);
|
||||||
|
builder.append(", lowerLeftY=");
|
||||||
|
builder.append(lowerLeftY);
|
||||||
|
builder.append(", upperRightX=");
|
||||||
|
builder.append(upperRightX);
|
||||||
|
builder.append(", upperRightY=");
|
||||||
|
builder.append(upperRightY);
|
||||||
|
builder.append(", crs=");
|
||||||
|
builder.append(crs);
|
||||||
|
builder.append("]");
|
||||||
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,28 +1,35 @@
|
||||||
package org.gcube.portlets.user.geoportaldataviewer.shared.gis;
|
package org.gcube.portlets.user.geoportaldataviewer.shared.gis;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
|
||||||
// TODO: Auto-generated Javadoc
|
|
||||||
/**
|
/**
|
||||||
* The Class ClickDataInfo.
|
* The Class GeoQuery.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
*
|
*
|
||||||
* Oct 27, 2020
|
* Oct 29, 2020
|
||||||
*/
|
*/
|
||||||
public class ClickDataInfo {
|
public class GeoQuery implements Serializable{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = 7500455699960112209L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Enum TYPE.
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||||
|
*
|
||||||
|
* Oct 29, 2020
|
||||||
|
*/
|
||||||
public static enum TYPE {
|
public static enum TYPE {
|
||||||
POINT,
|
POINT,
|
||||||
BOX
|
BOX
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The Constant THRESHOLD_AREA. */
|
|
||||||
private static final double THRESHOLD_AREA = 300;
|
|
||||||
|
|
||||||
/** The h. */
|
|
||||||
private int x, y, w, h;
|
|
||||||
|
|
||||||
/** The bbox. */
|
/** The bbox. */
|
||||||
private String bbox;
|
private String bbox;
|
||||||
|
|
||||||
|
@ -45,26 +52,6 @@ public class ClickDataInfo {
|
||||||
//ADDED BY FRANCESCO M.
|
//ADDED BY FRANCESCO M.
|
||||||
private int limit = Integer.MAX_VALUE;
|
private int limit = Integer.MAX_VALUE;
|
||||||
|
|
||||||
/**
|
|
||||||
* Instantiates a new click data info.
|
|
||||||
*
|
|
||||||
* @param x the x
|
|
||||||
* @param y the y
|
|
||||||
* @param w the w
|
|
||||||
* @param h the h
|
|
||||||
* @param bbox the bbox
|
|
||||||
*/
|
|
||||||
public ClickDataInfo(int x, int y, int w, int h, String bbox) {
|
|
||||||
super();
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
this.w = w;
|
|
||||||
this.h = h;
|
|
||||||
this.bbox = bbox;
|
|
||||||
this.type = TYPE.POINT;
|
|
||||||
// System.out.println("POINT SELECTED: x="+x+", y="+y+", w="+w+", h="+h+", bbox="+bbox);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new click data info.
|
* Instantiates a new click data info.
|
||||||
*
|
*
|
||||||
|
@ -72,8 +59,9 @@ public class ClickDataInfo {
|
||||||
* @param y1 the y 1
|
* @param y1 the y 1
|
||||||
* @param x2 the x 2
|
* @param x2 the x 2
|
||||||
* @param y2 the y 2
|
* @param y2 the y 2
|
||||||
|
* @param theType the the type
|
||||||
*/
|
*/
|
||||||
public ClickDataInfo(double x1, double y1, double x2, double y2) {
|
public GeoQuery(double x1, double y1, double x2, double y2, TYPE theType) {
|
||||||
this.x1 = x1;
|
this.x1 = x1;
|
||||||
this.y1 = y1;
|
this.y1 = y1;
|
||||||
this.x2 = x2;
|
this.x2 = x2;
|
||||||
|
@ -81,83 +69,11 @@ public class ClickDataInfo {
|
||||||
|
|
||||||
// note: the bounding box is left,lower,right,upper
|
// note: the bounding box is left,lower,right,upper
|
||||||
this.bbox = y1 +","+ x1 +","+ y2 +","+ x2;
|
this.bbox = y1 +","+ x1 +","+ y2 +","+ x2;
|
||||||
this.type = TYPE.BOX;
|
this.type = theType;
|
||||||
double area = (x2-x1) * (y2-y1);
|
double area = (x2-x1) * (y2-y1);
|
||||||
// System.out.println("BOX SELECTED: BBOX="+bbox + ", AREA="+area);
|
// System.out.println("BOX SELECTED: BBOX="+bbox + ", AREA="+area);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the x.
|
|
||||||
*
|
|
||||||
* @return the x
|
|
||||||
*/
|
|
||||||
public int getX() {
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the x.
|
|
||||||
*
|
|
||||||
* @param x the new x
|
|
||||||
*/
|
|
||||||
public void setX(int x) {
|
|
||||||
this.x = x;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the y.
|
|
||||||
*
|
|
||||||
* @return the y
|
|
||||||
*/
|
|
||||||
public int getY() {
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the y.
|
|
||||||
*
|
|
||||||
* @param y the new y
|
|
||||||
*/
|
|
||||||
public void setY(int y) {
|
|
||||||
this.y = y;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the w.
|
|
||||||
*
|
|
||||||
* @return the w
|
|
||||||
*/
|
|
||||||
public int getW() {
|
|
||||||
return w;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the w.
|
|
||||||
*
|
|
||||||
* @param w the new w
|
|
||||||
*/
|
|
||||||
public void setW(int w) {
|
|
||||||
this.w = w;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the h.
|
|
||||||
*
|
|
||||||
* @return the h
|
|
||||||
*/
|
|
||||||
public int getH() {
|
|
||||||
return h;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the h.
|
|
||||||
*
|
|
||||||
* @param h the new h
|
|
||||||
*/
|
|
||||||
public void setH(int h) {
|
|
||||||
this.h = h;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the bbox.
|
* Gets the bbox.
|
||||||
*
|
*
|
||||||
|
@ -194,19 +110,6 @@ public class ClickDataInfo {
|
||||||
return this.type==TYPE.BOX;
|
return this.type==TYPE.BOX;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if is hard query.
|
|
||||||
*
|
|
||||||
* @return true, if is hard query
|
|
||||||
*/
|
|
||||||
public boolean isHardQuery() {
|
|
||||||
if (this.isPoint())
|
|
||||||
return false;
|
|
||||||
else {
|
|
||||||
double area = (x2-x1) * (y2-y1);
|
|
||||||
return (area > THRESHOLD_AREA);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the x1.
|
* Gets the x1.
|
|
@ -4,3 +4,6 @@
|
||||||
/log4j.properties
|
/log4j.properties
|
||||||
/pred4s.gcubekey
|
/pred4s.gcubekey
|
||||||
/preprod.gcubekey
|
/preprod.gcubekey
|
||||||
|
/d4science.research-infrastructures.eu.gcubekey
|
||||||
|
/devVRE.gcubekey
|
||||||
|
/gCubeApps.gcubekey
|
||||||
|
|
Loading…
Reference in New Issue