geoetermia version

updated pom at 3.4.1

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/gis-viewer@97930 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2014-06-27 14:44:12 +00:00
parent 5cb86f4159
commit 4250bc4df8
10 changed files with 97 additions and 162 deletions

View File

@ -10,7 +10,7 @@
<groupId>org.gcube.portlets.user</groupId>
<artifactId>gis-viewer</artifactId>
<version>3.4.0-SNAPSHOT</version>
<version>3.4.1-SNAPSHOT</version>
<name>GIS Viewer Widget</name>
<description>
GIS Viewer Widget

View File

@ -5,7 +5,7 @@ import com.extjs.gxt.ui.client.widget.MessageBox;
public class Constants {
public static String VERSION = "3.4.0";
public static String VERSION = "3.4.1";
public static String defaultGroup=
// "5141",
// "groupTemplate",

View File

@ -365,8 +365,13 @@ implements ToolbarHandler, DataPanelHandler, LayersPanelHandler, CqlFilterHandle
urls.add(geoserverItem.getUrl() + urlRequest);
}
} else if (clickDataInfo.isBox()) {
for (LayerItem layerItem : visibleLayerItems)
urls.add(URLMakers.getWfsFeatureUrl(layerItem, clickDataInfo.getBbox(), 0, "csv"));
for (LayerItem layerItem : visibleLayerItems){
//ADDED BY FRANCESCO M.
int limit = clickDataInfo.getLimit()==Integer.MAX_VALUE?0:1;
urls.add(URLMakers.getWfsFeatureUrl(layerItem, clickDataInfo.getBbox(), limit, "csv"));
}
}
return urls;
@ -380,8 +385,7 @@ implements ToolbarHandler, DataPanelHandler, LayersPanelHandler, CqlFilterHandle
List<String> urls = gerUrlsForClickData(lastClickDataInfo);
mainPanel.setDataPanelWait(true);
gisViewerServiceAsync.getDataResult(urls,
new AsyncCallback<List<DataResult>>() {
gisViewerServiceAsync.getDataResult(urls,new AsyncCallback<List<DataResult>>() {
@Override
public void onSuccess(List<DataResult> result) {
DataResultPanel dpanel = new DataResultPanel();
@ -399,7 +403,10 @@ implements ToolbarHandler, DataPanelHandler, LayersPanelHandler, CqlFilterHandle
String bbox = lastClickDataInfo.getBbox();
mainPanel.setDataPanelWait(true);
gisViewerServiceAsync.getDataResult(layersPanel.getVisibleLayers(), bbox, new AsyncCallback<List<WfsTable>>() {
int maxWFSFeature = lastClickDataInfo.getLimit()==Integer.MAX_VALUE?Constants.MAX_WFS_FEATURES:lastClickDataInfo.getLimit();
GWT.log("Max WFS Feature is "+maxWFSFeature);
gisViewerServiceAsync.getDataResult(layersPanel.getVisibleLayers(), bbox, maxWFSFeature, new AsyncCallback<List<WfsTable>>() {
@Override
public void onSuccess(List<WfsTable> result) {
DataResultPanel dpanel = new DataResultPanel();
@ -789,6 +796,9 @@ implements ToolbarHandler, DataPanelHandler, LayersPanelHandler, CqlFilterHandle
// create a new click data information
lastClickDataInfo = new ClickDataInfo(x1, y1, x2, y2);
if(toolBarPanel.isPointDataTogglePressed())
lastClickDataInfo.setLimit(1);
// create a list of url request for data (for each geoserver)
showDataPanel();
}

View File

@ -40,6 +40,14 @@ public interface GisViewerService extends RemoteService {
*/
List<Property> getListProperty(String geoserverUrl, LayerItem layer);
/**
* @param layerItems
* @param bbox
* @param maxWFSFeature
* @return
*/
List<WfsTable> getDataResult(List<LayerItem> layerItems, String bbox, int maxWFSFeature);
// LayerItemsResult getLayersInfoByLayerConfigurations(List<LayerConfiguration> layerConfigurations);

View File

@ -31,6 +31,9 @@ public interface GisViewerServiceAsync {
void getListProperty(String geoserverUrl, LayerItem layer,
AsyncCallback<List<Property>> callback);
void getDataResult(List<LayerItem> layerItems, String bbox,
int maxWFSFeature, AsyncCallback<List<WfsTable>> callback);
// public void getLayersInfoByLayerConfigurations(List<LayerConfiguration> layerConfigurations, AsyncCallback<LayerItemsResult> asyncCallback);
}

View File

@ -5,7 +5,7 @@ package org.gcube.portlets.user.gisviewer.client.commons.utils;
* author: ceras
*/
public class ClickDataInfo {
private enum TYPE {POINT, BOX}
public static enum TYPE {POINT, BOX}
private static final double THRESHOLD_AREA = 300;
@ -18,17 +18,9 @@ public class ClickDataInfo {
private double x2;
private double y2;
// public ClickDataInfo(int x, int y, int w, int h, String bbox, List<GeoserverItem> geoserverItems) {
// super();
// this.x = x;
// this.y = y;
// this.w = w;
// this.h = h;
// this.bbox = bbox;
// this.geoserverItems = geoserverItems;
// this.type = TYPE.POINT;
// }
//ADDED BY FRANCESCO M.
private int limit = Integer.MAX_VALUE;
public ClickDataInfo(int x, int y, int w, int h, String bbox) {
super();
this.x = x;
@ -90,18 +82,6 @@ public class ClickDataInfo {
this.h = h;
}
// public void setGeoserverItems(List<GeoserverItem> geoserverItems) {
// this.geoserverItems = geoserverItems;
// }
//
// public List<GeoserverItem> getGeoserverItems() {
// return geoserverItems;
// }
//
// public void removeAllLayers() {
// this.geoserverItems.clear();
// }
public String getBbox() {
return bbox;
}
@ -154,4 +134,13 @@ public class ClickDataInfo {
public double getY2() {
return y2;
}
public int getLimit() {
return limit;
}
public void setLimit(int limit) {
this.limit = limit;
}
}

View File

@ -77,12 +77,23 @@ public class URLMakers {
* @return
*/
public static String getWfsFeatureUrl(LayerItem l, String bbox, int limit, String format) {
String link = l.getGeoserverUrl() + "/wfs?service=wfs&version=1.1.0&REQUEST=GetFeature" +
//COMMENTED 26/06/2014
// String link = l.getGeoserverUrl() + "/wfs?service=wfs&version=1.1.0&REQUEST=GetFeature" +
// "&TYPENAME=" + l.getLayer() +
// "&BBOX=" + bbox +
// (limit==0 ? "" : "&MAXFEATURES="+limit) +
// (format==null ? "" : "&OUTPUTFORMAT="+format);
//ADDED srsName=urn:x-ogc:def:crs:EPSG:4326
String link = l.getGeoserverUrl() + "/wfs?service=wfs&version=1.1.0&REQUEST=GetFeature&srsName=urn:x-ogc:def:crs:EPSG:4326" +
"&TYPENAME=" + l.getLayer() +
"&BBOX=" + bbox +
(limit==0 ? "" : "&MAXFEATURES="+limit) +
(format==null ? "" : "&OUTPUTFORMAT="+format);
//System.out.println("WFS: "+link);
//TODO ADD LOGGER
System.out.println("WFS: "+link);
return link;
}

View File

@ -309,4 +309,20 @@ public class ToolBarPanel extends ToolBar {
private void addProjectionBox(){
// TODO
}
/**
* Added by Francesco M.
* @return
*/
public boolean isPointDataTogglePressed(){
return clickDataToggle.isPressed();
}
/**
* Added by Francesco M.
* @return
*/
public boolean isBoxDataTogglePressed(){
return boxDataToggle.isPressed();
}
}

View File

@ -347,119 +347,6 @@ public abstract class GisViewerServiceImpl extends RemoteServiceServlet implemen
layerItem.setProperties(properties);
}
// String gsUrl = layerItem.getGeoserverUrl();
// String layerName = layerItem.getName();
// try {
// if (gsUrl==null)
// throw new Exception();
//
// GeoserverCaller geoserverCaller;
// GisViewerServiceParameters parameters = getParameters();
// String gsUser = parameters.getGeoServerUser();
// String gsPwd = parameters.getGeoServerPwd();
//
// geoserverCaller = new GeoserverCaller(gsUrl, gsUser, gsPwd);
//
// String gsGwcUrl = URLMakers.getGeoserverGwcUrl(gsUrl);
// String gsWmsUrl = URLMakers.getGeoserverWmsUrl(gsUrl);
// layerItem.setUrl(gsGwcUrl);
// layerItem.setGeoserverWmsUrl(gsWmsUrl);
//
// layerItem.setVisible((countVisible++)<2);
//
// LayerRest layerRest = geoserverCaller.getLayer(layerName);
//
// // set the dataStore
// layerItem.setDataStore(layerRest.getDatastore());
//
// layerItem.setDefaultStyle(layerRest.getDefaultStyle());
// layerItem.setStyle(layerRest.getDefaultStyle());
//
// layerItem.setBuffer(2);
//// layerItem.setLayer(ServerGeoExtCostants.workSpace+":" + layerName);
// if (layerRest.getType().contentEquals("RASTER")) {
// CoverageTypeRest coverageTypeRest = geoserverCaller.getCoverageType(
// layerRest.getWorkspace(),
// layerRest.getCoveragestore(),
// layerName);
//
// layerItem.setMaxExtent(coverageTypeRest.getLatLonBoundingBox().getMinx(),
// coverageTypeRest.getLatLonBoundingBox().getMiny(),
// coverageTypeRest.getLatLonBoundingBox().getMaxx(),
// coverageTypeRest.getLatLonBoundingBox().getMaxy(),
// coverageTypeRest.getLatLonBoundingBox().getCrs());
// layerItem.setHasLegend(false);
// layerItem.setBaseLayer(BASE_LAYER);
// layerItem.setTrasparent(false);
// layerItem.setClickData(false);
// } else {
// FeatureTypeRest featureTypeRest = geoserverCaller.getFeatureType(layerRest.getWorkspace(),
// layerRest.getDatastore(),
// layerName);
//
// layerItem.setMaxExtent(featureTypeRest.getLatLonBoundingBox().getMinx(),
// featureTypeRest.getLatLonBoundingBox().getMiny(),
// featureTypeRest.getLatLonBoundingBox().getMaxx(),
// featureTypeRest.getLatLonBoundingBox().getMaxy(),
// featureTypeRest.getLatLonBoundingBox().getCrs());
//
// layerItem.setBaseLayer(false);
// layerItem.setClickData(true);
// layerItem.setStyles(layerRest.getStyles());
// layerItem.setHasLegend(true);
//
// layerItem.setTrasparent(true);
// }
// layerItemsResult.addLayerItem(layerItem);
//
// // set layer properties info
// List<Property> properties = FeatureTypeParser.getProperties(gsUrl, layerItem.getLayer());
// layerItem.setProperties(properties);
//
// } catch (Exception e) {
// e.printStackTrace();
// layerItemsResult.addStatusMessage("- Layer \""+layerName+"\" not found.");
// }
// @Override
// public LayerItemsResult getLayersInfoByLayerConfigurations(List<LayerConfiguration> layerConfigurations) {
// LayerItemsResult layerItemsResult = new LayerItemsResult();
// Map<String, GeoserverCaller> geoserverCallers = new HashMap<String, GeoserverCaller>();
//
// for (LayerConfiguration layerConfiguration : layerConfigurations) {
// if (layerConfiguration.getLayerItem()!=null) {
// LayerItem layerItem = layerConfiguration.getLayerItem();
// try {
// if (!layerItem.isExternal())
// putLayerInfoInLayerItem(layerItem);
//
// layerItem.setVisible(layerConfiguration.isVisible());
// layerItem.setOpacity(layerConfiguration.getOpacity());
// layerItemsResult.addLayerItem(layerItem);
// } catch (Exception e) {
// e.printStackTrace();
// layerItemsResult.addStatusMessage("- Layer \""+layerItem.getName()+"\" not found.");
// }
// }
//
// else if (layerConfiguration.getLayerName()!=null) {
// String layerName = layerConfiguration.getLayerName();
//
// try {
// LayerItem layerItem = getLayerInfoByLayerName(layerName, geoserverCallers);
// layerItem.setVisible(layerConfiguration.isVisible());
// layerItem.setOpacity(layerConfiguration.getOpacity());
// layerItemsResult.addLayerItem(layerItem);
// } catch (Exception e) {
// e.printStackTrace();
// layerItemsResult.addStatusMessage("- Layer \""+layerName+"\" not found.");
// }
// }
// }
// return layerItemsResult;
// }
/**
* @param layerName
* @param geoserverCallers
@ -580,15 +467,19 @@ public abstract class GisViewerServiceImpl extends RemoteServiceServlet implemen
@Override
public List<WfsTable> getDataResult(List<LayerItem> layerItems, String bbox) {
List<WfsTable> result = FeatureParser.getDataResults(layerItems, bbox);
List<WfsTable> result = FeatureParser.getDataResults(layerItems, bbox, Constants.MAX_WFS_FEATURES);
return result;
}
@Override
public List<WfsTable> getDataResult(List<LayerItem> layerItems, String bbox, int maxWFSFeature) {
List<WfsTable> result = FeatureParser.getDataResults(layerItems, bbox, maxWFSFeature);
return result;
}
@Override
public List<Property> getListProperty(String geoserverUrl, LayerItem layer){
// System.out.println("getListProperty");
// set layer properties info
return FeatureTypeParser.getProperties(geoserverUrl, layer.getLayer());
}

View File

@ -48,20 +48,19 @@ public class FeatureParser {
private static Logger log = Logger.getLogger(FeatureParser.class);
/**
*
*/
// public FeatureParser(List<LayerItem> layerItems, String bbox) {
// this.layerItems = layerItems;
// this.bbox = bbox;
// public static List<WfsTable> getDataResults(List<LayerItem> layerItems, String bbox) {
// return getDataResults(layerItems, bbox, Constants.MAX_WFS_FEATURES);
// }
public static List<WfsTable> getDataResults(List<LayerItem> layerItems, String bbox) {
public static List<WfsTable> getDataResults(List<LayerItem> layerItems, String bbox, int maxWFSFeature) {
List<WfsTable> results = new ArrayList<WfsTable>();
if(maxWFSFeature<0)
maxWFSFeature = Constants.MAX_WFS_FEATURES;
for (LayerItem layerItem : layerItems)
results.add(getTableFromJson(layerItem, bbox));
results.add(getTableFromJson(layerItem, bbox, maxWFSFeature));
return results;
}
@ -127,17 +126,17 @@ public class FeatureParser {
return table;
}
/**
* @param layerItem
* @return
*/
private static WfsTable getTableFromJson(LayerItem layerItem, String bbox) {
private static WfsTable getTableFromJson(LayerItem layerItem, String bbox, int maxWFSFeature) {
final WfsTable table = new WfsTable();
table.setTitle(layerItem.getName());
try {
String url = URLMakers.getWfsFeatureUrl(layerItem, bbox, Constants.MAX_WFS_FEATURES, "json");
String url = URLMakers.getWfsFeatureUrl(layerItem, bbox, maxWFSFeature, "json");
InputStream is = new URL(url).openStream();
String jsonTxt = IOUtils.toString(is);
@ -173,6 +172,14 @@ public class FeatureParser {
return table;
}
// /**
// * @param layerItem
// * @return
// */
// private static WfsTable getTableFromJson(LayerItem layerItem, String bbox) {
// return getTableFromJson(layerItem, bbox, Constants.MAX_WFS_FEATURES);
// }
// PARSE TEST
private static void parse() {
String layer = "aquamaps:environments";
@ -237,7 +244,7 @@ public class FeatureParser {
l.setName("Eezall");
layerItems.add(l);
List<WfsTable> list = FeatureParser.getDataResults(layerItems, "86,0,180,1");
List<WfsTable> list = FeatureParser.getDataResults(layerItems, "86,0,180,1", 5);
for (WfsTable table: list) {
System.out.println("TABLE \""+ table.getTitle() +"\"");