fixing wsf query
This commit is contained in:
parent
8e7071bf6f
commit
5aa24f6198
|
@ -21,6 +21,8 @@ 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;
|
||||||
|
|
||||||
|
import ol.Coordinate;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class LayerManager.
|
* The Class LayerManager.
|
||||||
|
@ -63,12 +65,34 @@ public class LayerManager {
|
||||||
isLayerVisible(layerItem);
|
isLayerVisible(layerItem);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BoundsMap mapBBOX = new BoundsMap();
|
BoundsMap mapBBOX = new BoundsMap();
|
||||||
mapBBOX.setCrs(olMap.getProjectionCode());
|
//THIS IS SHOULD BE CORRET, THE BOUND AND CRS ARE READ FROM MAP
|
||||||
|
/*mapBBOX.setCrs(olMap.getProjectionCode());
|
||||||
mapBBOX.setLowerLeftX(olMap.getExtent().getLowerLeftX());
|
mapBBOX.setLowerLeftX(olMap.getExtent().getLowerLeftX());
|
||||||
mapBBOX.setLowerLeftY(olMap.getExtent().getLowerLeftY());
|
mapBBOX.setLowerLeftY(olMap.getExtent().getLowerLeftY());
|
||||||
mapBBOX.setUpperRightX(olMap.getExtent().getUpperRightX());
|
mapBBOX.setUpperRightX(olMap.getExtent().getUpperRightX());
|
||||||
mapBBOX.setUpperRightY(olMap.getExtent().getUpperRightY());
|
mapBBOX.setUpperRightY(olMap.getExtent().getUpperRightY());
|
||||||
|
*/
|
||||||
|
|
||||||
|
//THE FOLLOWING SHOULD BE NOT NEEDED BUT THE GETFEATURE WITH EPSG_3857 SEEMS NOT WORK IN OUR GEOSERVER
|
||||||
|
double minX = olMap.getExtent().getLowerLeftX();
|
||||||
|
double minY = olMap.getExtent().getLowerLeftY();
|
||||||
|
Coordinate centerCoordinate = new Coordinate(minX, minY);
|
||||||
|
centerCoordinate = olMap.transform(centerCoordinate, GeoportalDataViewerConstants.EPSG_3857, GeoportalDataViewerConstants.EPSG_4326);
|
||||||
|
mapBBOX.setLowerLeftX(centerCoordinate.getX());
|
||||||
|
mapBBOX.setLowerLeftY(centerCoordinate.getY());
|
||||||
|
|
||||||
|
double maxX = olMap.getExtent().getUpperRightX();
|
||||||
|
double maxY = olMap.getExtent().getUpperRightY();
|
||||||
|
centerCoordinate = new Coordinate(maxX,maxY);
|
||||||
|
centerCoordinate = olMap.transform(centerCoordinate, GeoportalDataViewerConstants.EPSG_3857, GeoportalDataViewerConstants.EPSG_4326);
|
||||||
|
mapBBOX.setUpperRightX(centerCoordinate.getX());
|
||||||
|
mapBBOX.setUpperRightY(centerCoordinate.getY());
|
||||||
|
|
||||||
|
mapBBOX.setCrs(GeoportalDataViewerConstants.EPSG_4326);
|
||||||
|
|
||||||
|
GWT.log("Bounds is: "+mapBBOX);
|
||||||
|
|
||||||
GeoportalDataViewerServiceAsync.Util.getInstance().getDataResult(layerItems, olMap.getProjectionCode(), mapBBOX, GeoportalDataViewerConstants.MAX_WFS_FEATURES, olMap.getCurrentZoomLevel(), new AsyncCallback<List<GeoNaDataObject>>() {
|
GeoportalDataViewerServiceAsync.Util.getInstance().getDataResult(layerItems, olMap.getProjectionCode(), mapBBOX, GeoportalDataViewerConstants.MAX_WFS_FEATURES, olMap.getCurrentZoomLevel(), new AsyncCallback<List<GeoNaDataObject>>() {
|
||||||
|
|
||||||
|
|
|
@ -421,6 +421,10 @@ public class OpenLayerOSM {
|
||||||
return this.map.getView().calculateExtent(map.getSize());
|
return this.map.getView().calculateExtent(map.getSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Coordinate transform (Coordinate centerCoordinate, String source, String target){
|
||||||
|
return Projection.transform(centerCoordinate, source, target);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ public class FeatureParser {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private static List<FeatureRow> getWFSFeatureProperties(LayerItem layerItem, String mapSrsName, BoundsMap mapBBOX, int maxWFSFeature) {
|
private static List<FeatureRow> getWFSFeatureProperties(LayerItem layerItem, String mapSrsName, BoundsMap mapBBOX, int maxWFSFeature) {
|
||||||
|
|
||||||
LOG.info("getTableFromJson -> Creating WfsTable to layerItem: "+layerItem.getName());
|
LOG.info("getWFSFeatureProperties for layerItem: "+layerItem.getName() +" in the "+mapBBOX);
|
||||||
InputStream is = null;
|
InputStream is = null;
|
||||||
List<FeatureRow> listFeaturesRow = new ArrayList<FeatureRow>();
|
List<FeatureRow> listFeaturesRow = new ArrayList<FeatureRow>();
|
||||||
try {
|
try {
|
||||||
|
@ -93,7 +93,7 @@ public class FeatureParser {
|
||||||
url = url.replace(notEncodedCQLFilter, toEncodeCQLFilter);
|
url = url.replace(notEncodedCQLFilter, toEncodeCQLFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.info("getTableFromJson -> WFS URL: "+url);
|
LOG.info("Built WFS URL: "+url);
|
||||||
is = new URL(url).openStream();
|
is = new URL(url).openStream();
|
||||||
String jsonTxt = IOUtils.toString(is);
|
String jsonTxt = IOUtils.toString(is);
|
||||||
|
|
||||||
|
@ -109,6 +109,7 @@ public class FeatureParser {
|
||||||
LOG.info("No features detected in the response, returning empty list");
|
LOG.info("No features detected in the response, returning empty list");
|
||||||
return listFeaturesRow;
|
return listFeaturesRow;
|
||||||
}
|
}
|
||||||
|
LOG.info("Features are: "+features.length());
|
||||||
|
|
||||||
for (int i=0; i<features.length(); i++) {
|
for (int i=0; i<features.length(); i++) {
|
||||||
final FeatureRow row = new FeatureRow();
|
final FeatureRow row = new FeatureRow();
|
||||||
|
@ -131,10 +132,8 @@ public class FeatureParser {
|
||||||
mapProperties.put(key, theValues);
|
mapProperties.put(key, theValues);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
row.setMapProperties(mapProperties);
|
row.setMapProperties(mapProperties);
|
||||||
listFeaturesRow.add(row);
|
listFeaturesRow.add(row);
|
||||||
|
|
||||||
LOG.info("Added row "+row+" to exported properties");
|
LOG.info("Added row "+row+" to exported properties");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,6 +145,7 @@ public class FeatureParser {
|
||||||
IOUtils.closeQuietly(is);
|
IOUtils.closeQuietly(is);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOG.info("Returning "+listFeaturesRow.size()+" features");
|
||||||
return listFeaturesRow;
|
return listFeaturesRow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,8 @@ import org.gcube.portlets.user.geoportaldataviewer.server.gis.MapServerRecognize
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.server.util.URLParserUtil;
|
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.BoundsMap;
|
||||||
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
|
import org.gcube.portlets.user.geoportaldataviewer.shared.gis.LayerItem;
|
||||||
|
import org.slf4j.Logger;
|
||||||
import com.google.gwt.core.shared.GWT;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,6 +31,8 @@ public class GisMakers {
|
||||||
|
|
||||||
private static String[][] a = { { "\\?", "%3F" }, { "&", "%26" }, };
|
private static String[][] a = { { "\\?", "%3F" }, { "&", "%26" }, };
|
||||||
|
|
||||||
|
private static final Logger LOG = LoggerFactory.getLogger(GisMakers.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Enum COORDINATE_FORMAT.
|
* The Enum COORDINATE_FORMAT.
|
||||||
*
|
*
|
||||||
|
@ -56,35 +58,35 @@ public class GisMakers {
|
||||||
public static String buildWFSFeatureQuery(LayerItem layerItem, String mapSrsName, BoundsMap mapBBOX, int maxFeatures, String outputFormat) {
|
public static String buildWFSFeatureQuery(LayerItem layerItem, String mapSrsName, BoundsMap mapBBOX, int maxFeatures, String outputFormat) {
|
||||||
|
|
||||||
String link = layerItem.getMapServerHost();
|
String link = layerItem.getMapServerHost();
|
||||||
GWT.log("Map server host URL: " + link);
|
LOG.debug("Map server host URL: " + link);
|
||||||
GWT.log("CQL filter is: " + layerItem.getCqlFilter());
|
LOG.debug("CQL filter is: " + layerItem.getCqlFilter());
|
||||||
|
|
||||||
String outputformat = null;
|
String outputformat = null;
|
||||||
String boundingBox = "";
|
String boundingBox = "";
|
||||||
|
|
||||||
// CASE MAP SERVER
|
// CASE MAP SERVER
|
||||||
SERVERTYPE mapserverType = MapServerRecognize.recongnize(layerItem);
|
SERVERTYPE mapserverType = MapServerRecognize.recongnize(layerItem);
|
||||||
GWT.log("Recongnized SERVERTYPE: " + mapserverType);
|
LOG.debug("Recongnized SERVERTYPE: " + mapserverType);
|
||||||
|
|
||||||
|
|
||||||
if (mapserverType != null) {
|
if (mapserverType != null) {
|
||||||
if (mapserverType.equals(SERVERTYPE.MAPSERVER)) {
|
if (mapserverType.equals(SERVERTYPE.MAPSERVER)) {
|
||||||
GWT.log("wms url contains wxs is a map server? no appending /wfs ");
|
LOG.debug("wms url contains wxs is a map server? no appending /wfs ");
|
||||||
outputformat = MapServerRecognize.outputFormatRecognize(SERVERTYPE.MAPSERVER, outputFormat);
|
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
|
boundingBox = BBOX_FORMAT(COORDINATE_FORMAT.YX, ",",mapBBOX.getLowerLeftX(),mapBBOX.getLowerLeftY(),mapBBOX.getUpperRightX(),mapBBOX.getUpperRightY()); // USE AXIS XY
|
||||||
// TODO DEBUG
|
// TODO DEBUG
|
||||||
GWT.log("SERVERTYPE.GEOSEVER outputformat: " + outputformat);
|
LOG.debug("SERVERTYPE.MAPSERVER outputformat: " + outputformat);
|
||||||
GWT.log("SERVERTYPE.GEOSEVER srsName: " + mapSrsName);
|
LOG.debug("SERVERTYPE.MAPSERVER srsName: " + mapSrsName);
|
||||||
|
LOG.debug("SERVERTYPE.MAPSERVER boundingBox: " + boundingBox);
|
||||||
|
} else {
|
||||||
|
LOG.debug("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;
|
||||||
|
boundingBox = BBOX_FORMAT(COORDINATE_FORMAT.YX, ",",mapBBOX.getLowerLeftX(),mapBBOX.getLowerLeftY(),mapBBOX.getUpperRightX(),mapBBOX.getUpperRightY()); // USE AXIS XY
|
||||||
|
// TODO DEBUG
|
||||||
|
LOG.debug("SERVERTYPE.GEOSEVER outputformat: " + outputformat);
|
||||||
|
LOG.debug("SERVERTYPE.GEOSEVER srsName: " + mapSrsName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
|
@ -119,7 +121,7 @@ public class GisMakers {
|
||||||
link += (boundingBox == null ? "" : "&BBOX=" + boundingBox);
|
link += (boundingBox == null ? "" : "&BBOX=" + boundingBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
GWT.log("WFS: " + link);
|
LOG.info("WFS: " + link);
|
||||||
return link;
|
return link;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue