merged with Feature #19249

This commit is contained in:
Francesco Mangiacrapa 2020-05-13 17:57:52 +02:00
parent b755de5c2a
commit 084ca24a47
23 changed files with 818 additions and 27 deletions

View File

@ -6,6 +6,9 @@
<Change>[Task #19220]: CQL filtering (if activated for WMS) should be
applied also for GetFeature request
</Change>
<Change>[Task #19249]: add a geometry into map when selecting a row in
the data table
</Change>
</Changeset>
<Changeset
component="org.gcube.portlets-user.GISViewer.4-4-0" date="2020-04-21">

View File

@ -21,7 +21,7 @@ public class Constants {
public static final int WFS_COLUMN_WIDTH = 140;
public static final int SOUTH_PANEL_HEIGHT = 400;
public static final int SOUTH_PANEL_HEIGHT = 300;
// LOG AND INFO PRINTING
public static boolean printLog=false;

View File

@ -28,10 +28,13 @@ import org.gcube.portlets.user.gisviewer.client.commons.utils.WmsParameters;
import org.gcube.portlets.user.gisviewer.client.commons.utils.WmsUrlValidator;
import org.gcube.portlets.user.gisviewer.client.datafeature.DataPanelHandler;
import org.gcube.portlets.user.gisviewer.client.datafeature.DataResultPanel;
import org.gcube.portlets.user.gisviewer.client.event.TableRowSelectedEvent;
import org.gcube.portlets.user.gisviewer.client.event.TableRowSelectedEventHandler;
import org.gcube.portlets.user.gisviewer.client.layerspanel.LayersPanel;
import org.gcube.portlets.user.gisviewer.client.layerspanel.LayersPanelHandler;
import org.gcube.portlets.user.gisviewer.client.openlayers.CqlFilterHandler;
import org.gcube.portlets.user.gisviewer.client.openlayers.CqlFilterPanel;
import org.gcube.portlets.user.gisviewer.client.openlayers.GeoJSONExt;
import org.gcube.portlets.user.gisviewer.client.openlayers.OpenLayersHandler;
import org.gcube.portlets.user.gisviewer.client.openlayers.OpenLayersMap;
import org.gcube.portlets.user.gisviewer.client.openlayers.ToolBarPanel;
@ -39,9 +42,12 @@ import org.gcube.portlets.user.gisviewer.client.openlayers.ToolbarHandler;
import org.gcube.portlets.user.gisviewer.client.resources.Images;
import org.gcube.portlets.user.gisviewer.client.resources.Resources;
import org.gcube.portlets.user.gisviewer.client.util.SizedLabel;
import org.gcube.portlets.user.gisviewer.shared.FeatureExportViewConfig;
import org.gwtopenmaps.openlayers.client.geometry.Geometry;
import com.extjs.gxt.ui.client.Style.Scroll;
import com.extjs.gxt.ui.client.core.XDOM;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.MessageBoxEvent;
@ -55,6 +61,7 @@ import com.google.gwt.event.dom.client.ErrorEvent;
import com.google.gwt.event.dom.client.ErrorHandler;
import com.google.gwt.event.dom.client.LoadEvent;
import com.google.gwt.event.dom.client.LoadHandler;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.http.client.URL;
import com.google.gwt.i18n.client.DateTimeFormat;
import com.google.gwt.user.client.Cookies;
@ -86,11 +93,14 @@ implements ToolbarHandler, DataPanelHandler, LayersPanelHandler, CqlFilterHandle
private GisViewerParameters parameters;
private String projection;
private CqlFilterPanel cqlFilterPanel = new CqlFilterPanel(this);
private Map<String, FeatureExportViewConfig> mapWFSViewConfig;
private ClickDataInfo lastClickDataInfo = null;
private GisViewerPanel INSTANCE;
protected List<GisViewerMapLoadedNotification.GisViewerMapLoadedtListener> listeners = new ArrayList<GisViewerMapLoadedtListener>();
private final static HandlerManager eventBus = new HandlerManager(null);
//ADDED BY FRANCESCO
/**
* The Enum LayerType.
@ -175,8 +185,106 @@ implements ToolbarHandler, DataPanelHandler, LayersPanelHandler, CqlFilterHandle
};
this.add(mainPanel);
addEventHandlers();
}
private void addEventHandlers() {
eventBus.addHandler(TableRowSelectedEvent.TYPE, new TableRowSelectedEventHandler() {
@Override
public void onTableRowSelected(TableRowSelectedEvent tableRowSelectedEvent) {
ModelData target = tableRowSelectedEvent.getTarget();
if(target!=null) {
displayGeometry(target);
}
}
});
}
private void displayGeometry(ModelData target) {
Map<String, Object> map = target.getProperties();
try {
//loading the value displayed in the table for 'geometry_type' and 'geometry_coordinates'
FeatureExportViewConfig theGeomType = mapWFSViewConfig.get("geometry_type");
String geomTypeDisplayedInTheTable = null;
if (theGeomType != null) {
geomTypeDisplayedInTheTable = theGeomType.getExportAs() != null && !theGeomType.getExportAs().isEmpty()
? theGeomType.getExportAs()
: theGeomType.getFeatureName();
}
FeatureExportViewConfig theGeomCoordiantes = mapWFSViewConfig.get("geometry_coordinates");
String geomCoordinatesDisplayedInTheTable = null;
if (theGeomType != null) {
geomCoordinatesDisplayedInTheTable = theGeomCoordiantes.getExportAs() != null && !theGeomCoordiantes.getExportAs().isEmpty()
? theGeomCoordiantes.getExportAs()
: theGeomCoordiantes.getFeatureName();
}
GWT.log("'geometry_type' key is displyed as: "+geomTypeDisplayedInTheTable);
GWT.log("'geometry_coordinates' key is displyed as: "+geomCoordinatesDisplayedInTheTable);
//these are the key of 'geometry_type' and 'geometry_coordinates' displayed in the table
if(geomTypeDisplayedInTheTable!=null && geomCoordinatesDisplayedInTheTable!=null) {
String geometryType = (String) map.get(geomTypeDisplayedInTheTable);
String geometryCoordinates = (String) map.get(geomCoordinatesDisplayedInTheTable);
if(geometryType!=null && geometryCoordinates!=null) {
/* String geoJson = GeoJSONExt.toGeoJsonString(geometryType, geometryCoordinates);
GWT.log("The geoJson string is: "+geoJson);
GeoJSONExt geoExt = new GeoJSONExt();
// Geometry theGeom = geo.toGeometry(geoJson);
Point centroidPoint = geoExt.getCentroidFromGeoJSON(geoJson);
GWT.log("Center of Centroid is lon: "+centroidPoint.getX() +", lat: "+centroidPoint.getY());
LonLat lonLatCentroid = new LonLat(centroidPoint.getX(), centroidPoint.getY());
openLayersMap.addMarker(lonLatCentroid);*/
String geoJson = GeoJSONExt.toGeoJsonString(geometryType, geometryCoordinates);
GWT.log("The geoJson string is: "+geoJson);
GeoJSONExt geoExt = new GeoJSONExt();
Geometry theGeom = geoExt.toGeometry(geoJson);
openLayersMap.addGeometry(theGeom);
}
}
//for bbox
// else {
//
// String bboxValue = (String) map.get("bbox");
// if(bboxValue!=null) {
// GWT.log("The bbox value is: "+bboxValue);
// //String bounds = Util.bboxToBounds(bboxValue);
// //Expected as array of coordinates like [lowerLeftX,lowerLeftY,upperRightX,upperRightY]
// String[] toCoordinate = bboxValue.replace("[", "").replace("]", "").split(",");
// if(toCoordinate.length==4) {
//
// Bounds theBounds = new Bounds(
// Double.parseDouble(toCoordinate[0]),
// Double.parseDouble(toCoordinate[1]),
// Double.parseDouble(toCoordinate[2]),
// Double.parseDouble(toCoordinate[3])
// );
// GWT.log("The bbox bounds is: "+theBounds.toString());
// openLayersMap.addMarker(theBounds.getCenterLonLat());
// }
// }
// }
}catch (Exception e) {
}
}
/* (non-Javadoc)
* @see com.extjs.gxt.ui.client.widget.LayoutContainer#onRender(com.google.gwt.user.client.Element, int)
*/
@ -190,8 +298,27 @@ implements ToolbarHandler, DataPanelHandler, LayersPanelHandler, CqlFilterHandle
}
getTransectUrl();
getMapWFStoViewExport();
};
private void getMapWFStoViewExport() {
gisViewerServiceAsync.getWFSToViewExporterMap(new AsyncCallback<Map<String,FeatureExportViewConfig>>() {
@Override
public void onFailure(Throwable caught) {
GWT.log("Error :"+caught);
}
@Override
public void onSuccess(Map<String, FeatureExportViewConfig> result) {
GWT.log("Loaded map: "+result);
mapWFSViewConfig = result;
}
});
}
/**
* Wait message.
*
@ -1209,6 +1336,10 @@ implements ToolbarHandler, DataPanelHandler, LayersPanelHandler, CqlFilterHandle
public OpenLayersMap getOpenLayersMap() {
return openLayersMap;
}
public static HandlerManager getEventbus() {
return eventBus;
}
/**
* Gets the tool bar panel.

View File

@ -2,6 +2,7 @@ package org.gcube.portlets.user.gisviewer.client;
import java.util.List;
import java.util.Map;
import org.gcube.portlets.user.gisviewer.client.commons.beans.DataResult;
import org.gcube.portlets.user.gisviewer.client.commons.beans.GeoInformationForWMSRequest;
@ -11,6 +12,7 @@ import org.gcube.portlets.user.gisviewer.client.commons.beans.Property;
import org.gcube.portlets.user.gisviewer.client.commons.beans.TransectParameters;
import org.gcube.portlets.user.gisviewer.client.commons.beans.WebFeatureTable;
import org.gcube.portlets.user.gisviewer.client.commons.beans.WmsRequest;
import org.gcube.portlets.user.gisviewer.shared.FeatureExportViewConfig;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@ -97,5 +99,13 @@ public interface GisViewerService extends RemoteService {
* @throws Exception the exception
*/
GeoInformationForWMSRequest parseWmsRequest(String wmsRequest, String layerName) throws Exception;
/**
* Gets the WFS to view exporter map.
*
* @return the WFS to view exporter map
*/
Map<String, FeatureExportViewConfig> getWFSToViewExporterMap() throws Exception;
}

View File

@ -2,6 +2,7 @@ package org.gcube.portlets.user.gisviewer.client;
import java.util.List;
import java.util.Map;
import org.gcube.portlets.user.gisviewer.client.commons.beans.DataResult;
import org.gcube.portlets.user.gisviewer.client.commons.beans.GeoInformationForWMSRequest;
@ -11,6 +12,7 @@ import org.gcube.portlets.user.gisviewer.client.commons.beans.Property;
import org.gcube.portlets.user.gisviewer.client.commons.beans.TransectParameters;
import org.gcube.portlets.user.gisviewer.client.commons.beans.WebFeatureTable;
import org.gcube.portlets.user.gisviewer.client.commons.beans.WmsRequest;
import org.gcube.portlets.user.gisviewer.shared.FeatureExportViewConfig;
import com.google.gwt.user.client.rpc.AsyncCallback;
@ -99,5 +101,14 @@ public interface GisViewerServiceAsync {
*/
void getGcubeSecurityToken(AsyncCallback<String> callback);
/**
* Gets the WFS to view exporter map.
*
* @param callback the callback
* @return the WFS to view exporter map
*/
void getWFSToViewExporterMap(AsyncCallback<Map<String, FeatureExportViewConfig>> callback);
}

View File

@ -4,7 +4,6 @@ package org.gcube.portlets.user.gisviewer.client.datafeature;
import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.user.gisviewer.client.Constants;
import org.gcube.portlets.user.gisviewer.client.commons.beans.DataResult;
import org.gcube.portlets.user.gisviewer.client.commons.beans.ResultColumn;
import org.gcube.portlets.user.gisviewer.client.commons.beans.ResultRow;
@ -16,10 +15,8 @@ import com.extjs.gxt.ui.client.widget.Html;
import com.extjs.gxt.ui.client.widget.TabItem;
import com.extjs.gxt.ui.client.widget.TabPanel;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnData;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.extjs.gxt.ui.client.widget.grid.Grid;
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer;
import com.extjs.gxt.ui.client.widget.layout.CenterLayout;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
@ -127,23 +124,28 @@ public class DataResultPanel extends TabPanel {
*/
public void setDataResultFromWfs(List<WebFeatureTable> result) {
for (WebFeatureTable table: result) {
TabItem item = new TabItem();
TabItem tabItem = new TabItem();
String title = table.getTitle();
if(table.getRows()!=null)
title = "("+table.getRows().size()+") " + title;
item.setText(title);
item.setClosable(true);
tabItem.setText(title);
tabItem.setClosable(true);
item.addStyleName("pad-text");
tabItem.addStyleName("pad-text");
if (table.isError()) {
item.setLayout(new CenterLayout());
item.add(new Html(MESSAGE_WFS_NOT_SUPPORTED));
tabItem.setLayout(new CenterLayout());
tabItem.add(new Html(MESSAGE_WFS_NOT_SUPPORTED));
}
else if (table.getRows().size()>0) {
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
GxtGridFilter gridFilterPanel = new GxtGridFilter(table.getColumnNames(), table.getRows());
tabItem.setLayout(new FitLayout());
tabItem.add(gridFilterPanel.getGrid());
/*List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
ListStore<BaseModel> listStore = new ListStore<BaseModel>();
List<String> columnNames = table.getColumnNames();
@ -184,8 +186,16 @@ public class DataResultPanel extends TabPanel {
grid.setStripeRows(true);
grid.setColumnLines(true);
grid.addListener(Events.Select, new Listener<BaseEvent>() {
@Override
public void handleEvent(BaseEvent be) {
GWT.log("");
}
});
item.setLayout(new FitLayout());
item.add(grid);
item.add(grid);*/
//adding the tool-tip to single cell value
/*QuickTip quickTip = new QuickTip(grid);
@ -209,10 +219,10 @@ public class DataResultPanel extends TabPanel {
} else {
item.setLayout(new CenterLayout());
item.add(new Html(MESSAGE_NO_DATA));
tabItem.setLayout(new CenterLayout());
tabItem.add(new Html(MESSAGE_NO_DATA));
}
this.add(item);
this.add(tabItem);
}
}
}

View File

@ -0,0 +1,182 @@
package org.gcube.portlets.user.gisviewer.client.datafeature;
import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.user.gisviewer.client.Constants;
import org.gcube.portlets.user.gisviewer.client.GisViewerPanel;
import org.gcube.portlets.user.gisviewer.client.event.TableRowSelectedEvent;
import com.extjs.gxt.ui.client.Style.SelectionMode;
import com.extjs.gxt.ui.client.data.BaseModel;
import com.extjs.gxt.ui.client.data.ModelData;
import com.extjs.gxt.ui.client.event.Listener;
import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
import com.extjs.gxt.ui.client.store.ListStore;
import com.extjs.gxt.ui.client.store.Store;
import com.extjs.gxt.ui.client.store.StoreEvent;
import com.extjs.gxt.ui.client.widget.grid.ColumnConfig;
import com.extjs.gxt.ui.client.widget.grid.ColumnData;
import com.extjs.gxt.ui.client.widget.grid.ColumnModel;
import com.extjs.gxt.ui.client.widget.grid.Grid;
import com.extjs.gxt.ui.client.widget.grid.GridCellRenderer;
import com.extjs.gxt.ui.client.widget.grid.filters.GridFilters;
import com.extjs.gxt.ui.client.widget.grid.filters.StringFilter;
import com.google.gwt.core.client.GWT;
/**
* The Class GxtGridFilter.
*
* @author Francesco Mangiacrapa at ISTI-CNR Pisa (Italy)
* May 12, 2020
*/
public class GxtGridFilter {
private Grid<BaseModel> grid;
private ListStore<BaseModel> store;
/**
* Instantiates a new gxt grid filter group panel.
*
* @param columnNames the column names
* @param dataRows the data rows
*/
public GxtGridFilter(List<String> columnNames, List<BaseModel> dataRows) {
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
store = new ListStore<BaseModel>();
// adding filters as String filter
GridFilters filters = new GridFilters();
filters.setLocal(true);
for (final String columnName : columnNames) {
ColumnConfig column = new ColumnConfig();
column.setId(columnName);
column.setHeader(columnName);
// set the renderer for the grid cell. Adding the tool-tip 'title'
column.setRenderer(new GridCellRenderer<BaseModel>() {
@Override
public Object render(BaseModel model, String property, ColumnData config, int rowIndex, int colIndex,
ListStore<BaseModel> store, Grid<BaseModel> grid) {
String value = model.get(property);
if (value != null) {
// return "<div qtitle='" + Format.htmlEncode(value) +
// "' qtip='" + Format.htmlEncode(value) +
// "'>" + value + "</div>";
// String thevalue = Format.htmlEncode(value);
String thevalue = value;
// GWT.log("value is: "+thevalue);
return "<span title='" + thevalue + "'>" + thevalue + "</span>";
}
return value;
}
});
column.setWidth(Constants.WFS_COLUMN_WIDTH);
configs.add(column);
StringFilter theStringFilter = new StringFilter(columnName);
filters.addFilter(theStringFilter);
}
store.add(dataRows);
ColumnModel cm = new ColumnModel(configs);
grid = new Grid<BaseModel>(store, cm);
grid.setBorders(false);
grid.setStripeRows(true);
grid.setColumnLines(true);
//grid.getView().setAutoFill(true);
//grid.getView().setForceFit(true);
//grid.getView().setShowDirtyCells(false);
grid.getView().setEmptyText("No data");
// adding plugin filter
grid.addPlugin(filters);
// selection listener
grid.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
grid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<BaseModel>() {
@Override
public void selectionChanged(SelectionChangedEvent<BaseModel> se) {
ModelData target = se.getSelectedItem();
if (target != null) {
GWT.log("selection grid change: "+target);
GisViewerPanel.getEventbus().fireEvent(new TableRowSelectedEvent(target));
}
}
});
grid.setContextMenu(null); // add context menu null - ignore browse event right click
addDataChangedStoreListener();
}
/**
* Gets the grid.
*
* @return the grid
*/
public Grid<BaseModel> getGrid() {
return grid;
}
/**
* Gets the selected item.
*
* @return the selected item
*/
public BaseModel getSelectedItem() {
return grid.getSelectionModel().getSelectedItem();
}
/**
* Gets the store.
*
* @return the store
*/
public ListStore<BaseModel> getStore() {
return store;
}
/**
* Adds the data changed store listener.
*/
private void addDataChangedStoreListener() {
store.addListener(Store.Add, new Listener<StoreEvent<ModelData>>() {
@Override
public void handleEvent(StoreEvent<ModelData> be) {
}
});
store.addListener(Store.Remove, new Listener<StoreEvent<ModelData>>() {
@Override
public void handleEvent(StoreEvent<ModelData> be) {
}
});
store.addListener(Store.Clear, new Listener<StoreEvent<ModelData>>() {
@Override
public void handleEvent(StoreEvent<ModelData> be) {
}
});
}
}

View File

@ -0,0 +1,54 @@
package org.gcube.portlets.user.gisviewer.client.event;
import com.extjs.gxt.ui.client.data.ModelData;
import com.google.gwt.event.shared.GwtEvent;
/**
* The Class TableRowSelectedEvent.
*
* @author Francesco Mangiacrapa at ISTI-CNR Pisa (Italy)
* May 12, 2020
*/
public class TableRowSelectedEvent extends GwtEvent<TableRowSelectedEventHandler> {
public static Type<TableRowSelectedEventHandler> TYPE = new Type<TableRowSelectedEventHandler>();
private ModelData target;
/**
* Instantiates a new table row selected event.
*
* @param target the target
*/
public TableRowSelectedEvent(ModelData target) {
this.target = target;
}
/**
* Gets the associated type.
*
* @return the associated type
*/
@Override
public Type<TableRowSelectedEventHandler> getAssociatedType() {
return TYPE;
}
/**
* Dispatch.
*
* @param handler the handler
*/
@Override
protected void dispatch(TableRowSelectedEventHandler handler) {
handler.onTableRowSelected(this);
}
/**
* Gets the target.
*
* @return the target
*/
public ModelData getTarget() {
return target;
}
}

View File

@ -0,0 +1,21 @@
package org.gcube.portlets.user.gisviewer.client.event;
import com.google.gwt.event.shared.EventHandler;
// TODO: Auto-generated Javadoc
/**
* The Interface TableRowSelectedEventHandler.
*
* @author Francesco Mangiacrapa at ISTI-CNR Pisa (Italy)
* May 12, 2020
*/
public interface TableRowSelectedEventHandler extends EventHandler {
/**
* On table row selected.
*
* @param tableRowSelectedEvent the table row selected event
*/
void onTableRowSelected(TableRowSelectedEvent tableRowSelectedEvent);
}

View File

@ -0,0 +1,183 @@
package org.gcube.portlets.user.gisviewer.client.openlayers;
import org.gwtopenmaps.openlayers.client.format.FormatImpl;
import org.gwtopenmaps.openlayers.client.format.GeoJSON;
import org.gwtopenmaps.openlayers.client.geometry.Geometry;
import org.gwtopenmaps.openlayers.client.geometry.Point;
import org.gwtopenmaps.openlayers.client.util.JSObject;
import com.google.gwt.core.client.GWT;
// TODO: Auto-generated Javadoc
/**
* The Class GeoJSONExt.
*
* @author Francesco Mangiacrapa at ISTI-CNR Pisa (Italy)
* May 12, 2020
*/
public class GeoJSONExt extends GeoJSON{
/**
* Instantiates a new geo JSON ext.
*/
public GeoJSONExt()
{
super();
}
/**
* Parses the geometry.
*
* @param geoJson the geo json
* @return the geometry
*/
public Geometry toGeometry(String geoJson){
String wktString = geoJSONtoWKT(geoJson);
Geometry theGeom = Geometry.fromWKT(wktString);
GWT.log("the theGeom read as WKT is: "+theGeom);
return theGeom;
}
/**
* Gets the centroid from geo JSON.
*
* @param geoJson the geo json
* @return the centroid from geo JSON
*/
public Point getCentroidFromGeoJSON(String geoJson){
JSObject jsonObj = getCentroidForGeoJSON(geoJson);
return narrowToPoint(jsonObj);
}
/**
* Parses the geometry.
*
* @param geoJson the geo json
* @return the geometry
*/
public Geometry toGeometryCentroid(String geoJson){
String wktString = geoJSONtoWKT(geoJson);
Geometry theGeom = Geometry.fromWKT(wktString);
GWT.log("the theGeom read as WKT is: "+theGeom);
return theGeom;
}
/**
* Narrow to geometry.
*
* @param element the element
* @return the geometry
*/
private static Geometry narrowToGeometry(JSObject element) {
return (element == null) ? null : new GeometryExt(element);
}
/**
* Narrow to point.
*
* @param element the element
* @return the point ext
*/
private static PointExt narrowToPoint(JSObject element) {
return (element == null) ? null : new PointExt(element);
}
/**
* Geo JSO nto WKT.
*
* @param geoJsonString the geo json string
* @return the string
*/
public static native String geoJSONtoWKT(String geoJsonString) /*-{
console.log('geoJsonString: '+geoJsonString);
var geojson_format = new $wnd.OpenLayers.Format.GeoJSON();
var theFeature = geojson_format.read(geoJsonString);
//var geomJSON = geojson_format.parseGeometry(theFeature);
var wkt_options = {};
var wkt = new $wnd.OpenLayers.Format.WKT(wkt_options);
var wktString = wkt.write(theFeature);
return wktString;
}-*/;
/**
* Gets the centroid for geo JSON.
*
* @param geoJsonString the geo json string
* @return the centroid for geo JSON
*/
public static native JSObject getCentroidForGeoJSON(String geoJsonString) /*-{
console.log('geoJsonString: '+geoJsonString);
var geojson_format = new $wnd.OpenLayers.Format.GeoJSON();
var theFeature = geojson_format.read(geoJsonString);
//var geomJSON = geojson_format.parseGeometry(theFeature);
var wkt_options = {};
var wkt = new $wnd.OpenLayers.Format.WKT(wkt_options);
var wktString = wkt.write(theFeature);
var geom = $wnd.OpenLayers.Geometry.fromWKT(wktString);
return geom.getCentroid();
}-*/;
/**
* Gets the JS object.
*
* @param geoJsonString the geo json string
* @return the JS object
*/
private JSObject getJSObject(String geoJsonString) {
return FormatImpl.read(getJSObject(), geoJsonString);
}
/**
* To geo json string.
*
* @param geometryType the geometry type
* @param geometryCoordinate the geometry coordinate
* @return the string
*/
public static String toGeoJsonString(String geometryType, String geometryCoordinate) {
// return $wnd.OpenLayers.Geometry.fromWKT(wkt);
// JSONObject json = new JSONObject();
// json.put("type", new com.google.gwt.json.client.JSONString("FeatureCollection"));
// JSONArray features = new JSONArray();
// json.put("features", features);
// JSONObject feature = new JSONObject();
// features.set(0, feature);
// feature.put("type", new com.google.gwt.json.client.JSONString("Feature"));
// JSONObject geometry = new JSONObject();
// feature.put("geometry", geometry);
// geometry.put("type", new com.google.gwt.json.client.JSONString(geometryType));
// geometry.put("coordinates", new com.google.gwt.json.client.JSONString(geometryCoordinate));
// return json.toString();
String geoJsonString = "{\"type\": \"FeatureCollection\","
+ "\"features\": ["
+ "{"
+ "\"type\": \"Feature\","
+ "\"geometry\": {"
+ "\"type\": \""+geometryType+"\","
+ "\"coordinates\": "+geometryCoordinate+""
+ "},"
+ "\"geometry_name\": \"the_geom\","
+ "\"properties\": {}"
+ "}]}";
return geoJsonString;
}
}

View File

@ -0,0 +1,23 @@
package org.gcube.portlets.user.gisviewer.client.openlayers;
import org.gwtopenmaps.openlayers.client.geometry.Geometry;
import org.gwtopenmaps.openlayers.client.util.JSObject;
// TODO: Auto-generated Javadoc
/**
* The Class GeometryExt.
*
* @author Francesco Mangiacrapa at ISTI-CNR Pisa (Italy) May 12, 2020
*/
public class GeometryExt extends Geometry {
/**
* Instantiates a new geometry ext.
*
* @param element the element
*/
public GeometryExt(JSObject element) {
super(element);
}
}

View File

@ -20,6 +20,7 @@ import org.gwtopenmaps.openlayers.client.MapWidget;
import org.gwtopenmaps.openlayers.client.Marker;
import org.gwtopenmaps.openlayers.client.Pixel;
import org.gwtopenmaps.openlayers.client.Size;
import org.gwtopenmaps.openlayers.client.Style;
import org.gwtopenmaps.openlayers.client.ZIndexBase;
import org.gwtopenmaps.openlayers.client.control.Control;
import org.gwtopenmaps.openlayers.client.control.DrawFeature;
@ -86,6 +87,7 @@ public class OpenLayersMap {
private MouseDefaults mouseDefaults;
private int numZoomLevels = 0;
private Vector vectorLayer;
private Vector geometryLayer;
private ZoomBox zoomBox;
private boolean clickData = false;
private String tableTransect = "";
@ -101,6 +103,8 @@ public class OpenLayersMap {
private ToolBarPanel toolBarPanel;
private List<GisViewerBaseLayerInterface> baseLayersIntefaces;
private TransectParameters transect;
private Markers layerMarkers;
//ADDED BY FRANCESCO M. TO FIX # support 832
/**
@ -490,7 +494,7 @@ public class OpenLayersMap {
//vectorLayer.setZIndex(MAX_ZINDEX);
}
/**
/**markers
* Adds the tool bar.
*
* @param toolBarPanel the tool bar panel
@ -563,14 +567,55 @@ public class OpenLayersMap {
}
public void addMarker(LonLat lonLat) {
Markers markers = new Markers("Markers");
map.addLayer(markers);
Size size = new Size(21,25);
if(lonLat==null)
return;
if(layerMarkers==null) {
layerMarkers = new Markers("Feature Markers");
layerMarkers.setDisplayInLayerSwitcher(false);
map.addLayer(layerMarkers);
}else {
layerMarkers.clearMarkers();
}
Size size = new Size(32,32);
Pixel offset = new Pixel(-(size.getWidth()/2), -size.getHeight());
Icon icon = new Icon(Images.mapMarked().createImage().getUrl(), size, offset);
markers.addMarker(new Marker(lonLat,icon));
//markers.addMarker(new Marker(lonLat,icon.clone()));
GWT.log("Add marker to lon: "+lonLat.lon() + " lat: "+lonLat.lat());
layerMarkers.addMarker(new Marker(lonLat,icon));
}
public void addGeometry(Geometry theGeom) {
if(theGeom==null)
return;
if(geometryLayer==null) {
geometryLayer = new Vector("Feature selected");
geometryLayer.setDisplayInLayerSwitcher(false);
map.addLayer(geometryLayer);
}else {
geometryLayer.removeAllFeatures();
}
Style style = new Style();
style.setFillColor("#00FF00");
style.setGraphicName("circle");
style.setPointRadius(10);
VectorFeature vf = new VectorFeature(theGeom, style);
geometryLayer.addFeature(vf);
}
protected void removeGeometries() {
if(geometryLayer!=null)
geometryLayer.removeAllFeatures();
}
protected void removeMarkers() {
if(layerMarkers!=null)
layerMarkers.clearMarkers();
}
/**

View File

@ -0,0 +1,33 @@
package org.gcube.portlets.user.gisviewer.client.openlayers;
import org.gwtopenmaps.openlayers.client.geometry.Point;
import org.gwtopenmaps.openlayers.client.util.JSObject;
/**
* The Class PointExt.
*
* @author Francesco Mangiacrapa at ISTI-CNR Pisa (Italy)
* May 13, 2020
*/
public class PointExt extends Point{
/**
* Instantiates a new point ext.
*
* @param x the x
* @param y the y
*/
public PointExt(double x, double y) {
super(x, y);
}
/**
* Instantiates a new point ext.
*
* @param point the point
*/
public PointExt(JSObject point){
super(point);
}
}

View File

@ -270,6 +270,8 @@ public class ToolBarPanel extends ToolBar {
@Override
public void componentSelected(ButtonEvent ce) {
om.removeDataFeature();
om.removeMarkers();
om.removeGeometries();
}
});
}

View File

@ -1,7 +1,17 @@
package org.gcube.portlets.user.gisviewer.client.openlayers;
public class Util {
public static native String getFormattedLonLat(double coordinate, String axis, String dmsOption)/*-{
return $wnd.OpenLayers.Util.getFormattedLonLat(coordinate, axis, dmsOption);
}-*/;
public static native String bboxToBounds(String array)/*-{
return $wnd.OpenLayers.Bounds.fromArray(array);
}-*/;
public static native String jsonToGeometry(String geoJson)/*-{
return $wnd.OpenLayers.Format.JSON(array);
}-*/;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -21,6 +21,10 @@ import org.gcube.portlets.user.gisviewer.client.commons.beans.ZAxis;
import org.gcube.portlets.user.gisviewer.server.datafeature.ClickDataParser;
import org.gcube.portlets.user.gisviewer.server.datafeature.FeatureParser;
import org.gcube.portlets.user.gisviewer.server.datafeature.FeatureTypeParser;
import org.gcube.portlets.user.gisviewer.server.datafeature.wfs.FeatureExporterFileConfig;
import org.gcube.portlets.user.gisviewer.server.datafeature.wfs.WFSExporter;
import org.gcube.portlets.user.gisviewer.server.datafeature.wfs.WFSExporter.WFS_TO;
import org.gcube.portlets.user.gisviewer.shared.FeatureExportViewConfig;
import org.gcube.spatial.data.geoutility.GeoNcWMSMetadataUtility;
import org.gcube.spatial.data.geoutility.bean.LayerStyles;
import org.gcube.spatial.data.geoutility.bean.LayerZAxis;
@ -219,5 +223,14 @@ public abstract class GisViewerServiceImpl extends RemoteServiceServlet implemen
throw new Exception("Sorry, an error occurred when creating wms request, try again later");
}
}
@Override
public Map<String, FeatureExportViewConfig> getWFSToViewExporterMap(){
logger.debug("getWFSToViewExporterMap called");
WFSExporter exporter = new WFSExporter();
FeatureExporterFileConfig wfsExport = exporter.getWFSExporterConfigTo(WFS_TO.VIEW);
return wfsExport.getMap();
}
}

View File

@ -5,16 +5,34 @@ import java.util.Map;
import org.gcube.portlets.user.gisviewer.server.datafeature.wfs.WFSExporter.WFS_TO;
import org.gcube.portlets.user.gisviewer.shared.CSVFile;
import org.gcube.portlets.user.gisviewer.shared.FeatureExportViewConfig;
/**
* The Class FeatureExporterFileConfig.
*
* @author Francesco Mangiacrapa at ISTI-CNR Pisa (Italy)
* May 13, 2020
*/
public class FeatureExporterFileConfig {
private CSVFile file;
private Map<String, FeatureExportViewConfig> map = new HashMap<String, FeatureExportViewConfig>();
private WFS_TO wfsTo;
/**
* Instantiates a new feature exporter file config.
*/
public FeatureExporterFileConfig() {
}
/**
* Instantiates a new feature exporter file config.
*
* @param file the file
* @param map the map
* @param wfsTo the wfs to
*/
public FeatureExporterFileConfig(CSVFile file, Map<String, FeatureExportViewConfig> map, WFS_TO wfsTo) {
super();
this.file = file;
@ -22,30 +40,65 @@ public class FeatureExporterFileConfig {
this.wfsTo = wfsTo;
}
/**
* Gets the wfs to.
*
* @return the wfs to
*/
public WFS_TO getWfsTo() {
return wfsTo;
}
/**
* Sets the wfs to.
*
* @param wfsTo the new wfs to
*/
public void setWfsTo(WFS_TO wfsTo) {
this.wfsTo = wfsTo;
}
/**
* Gets the file.
*
* @return the file
*/
public CSVFile getFile() {
return file;
}
/**
* Sets the file.
*
* @param file the new file
*/
public void setFile(CSVFile file) {
this.file = file;
}
/**
* Gets the map.
*
* @return the map
*/
public Map<String, FeatureExportViewConfig> getMap() {
return map;
}
/**
* Sets the map.
*
* @param map the map
*/
public void setMap(Map<String, FeatureExportViewConfig> map) {
this.map = map;
}
/**
* To string.
*
* @return the string
*/
@Override
public String toString() {
return "FeatureExporterFileConfig [file=" + file + ", map=" + map + ", wfsTo=" + wfsTo + "]";

View File

@ -21,6 +21,7 @@ import org.gcube.portlets.user.gisviewer.server.util.JSONUtil;
import org.gcube.portlets.user.gisviewer.server.util.URLParserUtil;
import org.gcube.portlets.user.gisviewer.shared.CSVFile;
import org.gcube.portlets.user.gisviewer.shared.CSVRow;
import org.gcube.portlets.user.gisviewer.shared.FeatureExportViewConfig;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

View File

@ -7,8 +7,6 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
// TODO: Auto-generated Javadoc
/**
* The Class CSVFile.
*

View File

@ -1,7 +1,15 @@
package org.gcube.portlets.user.gisviewer.server.datafeature.wfs;
package org.gcube.portlets.user.gisviewer.shared;
public class FeatureExportViewConfig {
import java.io.Serializable;
public class FeatureExportViewConfig implements Serializable{
/**
*
*/
private static final long serialVersionUID = -3434624690746503690L;
private String featureName;
private boolean export;
private String exportAs;

View File

@ -3,10 +3,10 @@ package org.gcube.portlets.user.gisviewer.test.client;
import java.util.Map;
import org.gcube.portlets.user.gisviewer.client.commons.beans.LayerItem;
import org.gcube.portlets.user.gisviewer.server.datafeature.wfs.FeatureExportViewConfig;
import org.gcube.portlets.user.gisviewer.server.datafeature.wfs.WFSExporter;
import org.gcube.portlets.user.gisviewer.server.datafeature.wfs.WFSExporter.WFS_TO;
import org.gcube.portlets.user.gisviewer.shared.CSVFile;
import org.gcube.portlets.user.gisviewer.shared.FeatureExportViewConfig;
public class WfsTableExporter {