starting WFS getfeature
This commit is contained in:
parent
b414b21016
commit
eb0b78da87
|
@ -6,7 +6,6 @@ import com.github.gwtbootstrap.client.ui.Button;
|
|||
import com.github.gwtbootstrap.client.ui.ButtonGroup;
|
||||
import com.github.gwtbootstrap.client.ui.Tab;
|
||||
import com.github.gwtbootstrap.client.ui.constants.IconType;
|
||||
import com.github.gwtbootstrap.client.ui.constants.ToggleType;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.client.ui.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.Button;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
|
||||
/**
|
||||
* The Class MutuallyExclusiveToggleButtonCollection.
|
||||
*
|
||||
* @author Francesco Mangiacrapa at ISTI-CNR (francesco.mangiacrapa@isti.cnr.it)
|
||||
*
|
||||
* Oct 28, 2020
|
||||
*/
|
||||
public class MutuallyExclusiveToggleButtonCollection {
|
||||
|
||||
/** The list toggle button. */
|
||||
List<Button> listToggleButton = new ArrayList<Button>();
|
||||
|
||||
/**
|
||||
* Adds the.
|
||||
*
|
||||
* @param button the button
|
||||
*/
|
||||
public void add(Button button) {
|
||||
listToggleButton.add(button);
|
||||
button.addClickHandler(new ExclusiveButtonClickHandler());
|
||||
}
|
||||
|
||||
private class ExclusiveButtonClickHandler implements ClickHandler {
|
||||
|
||||
public void onClick(ClickEvent event) {
|
||||
for (Button button : listToggleButton) {
|
||||
GWT.log("Toggle button: " + button.getElement().getId());
|
||||
boolean isSource = event.getSource().equals(button);
|
||||
GWT.log("Set active: " + isSource);
|
||||
button.setActive(isSource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,80 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.geoportaldataviewer.client.util;
|
||||
|
||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
|
||||
|
||||
import com.google.gwt.core.shared.GWT;
|
||||
|
||||
/**
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* @Aug 29, 2014
|
||||
*
|
||||
*THIS CLASS DISCRIMINATES BETWEEN GEOSERVER AND MAPSERVER
|
||||
*ACCORDING TO THE VALUE OF LAYER URL
|
||||
*/
|
||||
public class MapServerRecognize {
|
||||
|
||||
public static enum SERVERTYPE{GEOSEVER, MAPSERVER};
|
||||
|
||||
public static SERVERTYPE recongnize(LayerItem l){
|
||||
|
||||
if(l==null)
|
||||
return null;
|
||||
|
||||
return recongnize(l.getUrl());
|
||||
}
|
||||
|
||||
public static SERVERTYPE recongnize(String baseServerUrl){
|
||||
|
||||
if(baseServerUrl==null || baseServerUrl.isEmpty())
|
||||
return null;
|
||||
|
||||
//CASE MAP SERVER
|
||||
if(baseServerUrl.contains(URLMakers.WXS)){
|
||||
GWT.log("wms url contains 'wxs' returning "+SERVERTYPE.MAPSERVER);
|
||||
return SERVERTYPE.MAPSERVER;
|
||||
}else{
|
||||
GWT.log("wms url doesn't contains 'wxs' returning "+SERVERTYPE.GEOSEVER);
|
||||
//CASE GEOSEVER
|
||||
return SERVERTYPE.GEOSEVER;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param serverType
|
||||
* @param output
|
||||
* @return
|
||||
*/
|
||||
public static String outputFormatRecognize(SERVERTYPE serverType, String output){
|
||||
|
||||
if(output==null || output.isEmpty())
|
||||
return output;
|
||||
|
||||
if(serverType==null)
|
||||
return output;
|
||||
|
||||
switch (serverType) {
|
||||
|
||||
case GEOSEVER:
|
||||
if(output.contains(URLMakers.JSON))
|
||||
return "json";
|
||||
else if(output.contains(URLMakers.CSV))
|
||||
return "csv";
|
||||
break;
|
||||
|
||||
case MAPSERVER:
|
||||
|
||||
if(output.contains(URLMakers.JSON))
|
||||
return "application/json;%20subtype=geojson";
|
||||
else if(output.contains(URLMakers.CSV))
|
||||
return "csv";
|
||||
break;
|
||||
}
|
||||
|
||||
return output;
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package org.gcube.portlets.user.geoportaldataviewer.client.util;
|
||||
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
|
||||
/**
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* @Sep 4, 2013
|
||||
*
|
||||
*/
|
||||
public final class NewBrowserWindow extends JavaScriptObject {
|
||||
// All types that extend JavaScriptObject must have a protected,
|
||||
// no-args constructor.
|
||||
protected NewBrowserWindow() {
|
||||
}
|
||||
|
||||
public static native NewBrowserWindow open(String url, String target,
|
||||
String options) /*-{
|
||||
return $wnd.open(url, target, options);
|
||||
}-*/;
|
||||
|
||||
public native void close() /*-{
|
||||
this.close();
|
||||
}-*/;
|
||||
|
||||
public native void setUrl(String url) /*-{
|
||||
if (this.location) {
|
||||
this.location = url;
|
||||
}
|
||||
}-*/;
|
||||
}
|
|
@ -0,0 +1,273 @@
|
|||
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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue