85 lines
4.1 KiB
Java
85 lines
4.1 KiB
Java
package org.gcube.portlets.user.geoportaldataviewer;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import org.gcube.spatial.data.geoutility.GeoWmsServiceUtility;
|
|
import org.gcube.spatial.data.geoutility.bean.WmsParameters;
|
|
import org.gcube.spatial.data.geoutility.util.HttpRequestUtil;
|
|
import org.gcube.spatial.data.geoutility.wms.WmsUrlValidator;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
/**
|
|
* The Class WMSUrlValidatorTest.
|
|
*
|
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
|
*
|
|
* Jun 1, 2023
|
|
*/
|
|
public class WMSUrlValidatorTest {
|
|
|
|
/**
|
|
* The main method.
|
|
*
|
|
* @param args the arguments
|
|
*/
|
|
public static void main(String[] args) {
|
|
|
|
// String baseGeoserverUrl = "http://repoigg.services.iit.cnr.it:8080/geoserver/IGG/ows";
|
|
// String baseGeoserverUrl = "http://www.fao.org/figis/geoserver/species";
|
|
// String fullPath = "http://www.fao.org/figis/geoserver/species?SERVICE=WMS&BBOX=-176.0,-90.0,180.0,90&styles=Species_prob, puppa&layers=layerName&FORMAT=image/gif";
|
|
// String fullPath = "http://repoigg.services.iit.cnr.it:8080/geoserver/IGG/ows?service=wms&version=1.1.0&request=GetMap&layers==IGG:area_temp_1000&width=676&height=330&srs=EPSG:4326&crs=EPSG:4326&format=application/openlayers&bbox=-85.5,-180.0,90.0,180.0";
|
|
// String baseGeoserverUrl = "http://thredds-d-d4s.d4science.org/thredds/wms/public/netcdf/test20.nc";
|
|
// String fullPath = "http://thredds-d-d4s.d4science.org/thredds/wms/public/netcdf/test20.nc?service=wms&version=1.3.0&request=GetMap&layers=analyzed_field&bbox=-85.0,-180.0,85.0,180.0&styles=&width=640&height=480&srs=EPSG:4326&CRS=EPSG:4326&format=image/png&COLORSCALERANGE=auto";
|
|
// WmsUrlValidator validator = new WmsUrlValidator(baseGeoserverUrl, fullPath , "", false);
|
|
// logger.trace("base wms service url: "+validator.getBaseWmsServiceUrl());
|
|
// logger.trace("layer name: "+validator.getLayerName());
|
|
// logger.trace("full wms url: "+validator.getFullWmsUrlRequest(false, true));
|
|
// logger.trace("style: "+validator.getStyles());
|
|
// logger.trace("not standard parameter: "+validator.getWmsNotStandardParameters());
|
|
// String[] arrayStyle = validator.getStyles().split(",");
|
|
//
|
|
// if(arrayStyle!=null && arrayStyle.length>0){
|
|
//
|
|
// for (String style : arrayStyle) {
|
|
// if(style!=null && !style.isEmpty())
|
|
//
|
|
// System.out.println("Style: "+style.trim());
|
|
// }
|
|
// }
|
|
//
|
|
// String fullPath = "http://thredds-d-d4s.d4science.org/thredds/wms/public/netcdf/test20.nc?service=wms&version=1.3.0&request=GetMap&layers=analyzed_field&bbox=-85.0,-180.0,85.0,180.0&styles=&width=640&height=480&srs=EPSG:4326&CRS=EPSG:4326&format=image/png&COLORSCALERANGE=auto";
|
|
//
|
|
// WmsGeoExplorerUrlValidator validator = new WmsGeoExplorerUrlValidator("http://thredds-d-d4s.d4science.org/thredds/wms/public/netcdf/test20.nc", fullPath , "", false);
|
|
// validator.getFullWmsUrlRequest(false,true);
|
|
//
|
|
// System.out.println(validator.getWmsNoStandardParameters());
|
|
// System.out.println(validator.getMapWmsNoStandardParams());
|
|
|
|
// fullPath = WmsUrlValidator.setValueOfParameter(WmsParameters.STYLES, fullPath, "123", true);
|
|
//
|
|
|
|
// MapPreviewGenerator map = new MapPreviewGenerator();
|
|
// fullPath = map.buildWmsRequestMapPreview(fullPath, "-85.0,-180.0,85.0,180.0");
|
|
// System.out.println(fullPath);
|
|
|
|
String wmsRequest = "http://geoserver-dev.d4science-ii.research-infrastructures.eu/geoserver/wms?CRS=EPSG:4326&BBOX=-85.5,-180.0,90.0,180.0&VERSION=1.1.0&FORMAT=application/openlayers&SERVICE=wms&HEIGHT=330&LAYERS=aquamaps:lsoleasolea20130716162322254cest&REQUEST=GetMap&STYLES=Species_prob&SRS=EPSG:4326&WIDTH=676";
|
|
// String wmsRequest = "http://thredds-d-d4s.d4science.org/thredds/wms/public/netcdf/test20.nc?service=wms&version=1.3.0&request=GetMap&layers=analyzed_field&styles=&width=640&height=480&srs=EPSG:4326&CRS=EPSG:4326&format=image/png&COLORSCALERANGE=auto&bbox=-85.0,-180.0,85.0,180.0";
|
|
WmsUrlValidator wms;
|
|
try {
|
|
wms = new WmsUrlValidator(wmsRequest);
|
|
System.out.println("Returned wms: "+wms.toString());
|
|
}
|
|
catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|