ecological-engine-geospatia.../src/main/java/org/gcube/dataanalysis/geo/meta/OGCFormatter.java

38 lines
2.1 KiB
Java

package org.gcube.dataanalysis.geo.meta;
public class OGCFormatter {
public static String getWfsUrl(String geoServerUrl, String layerName, String bbox, int limit, String format) {
return geoServerUrl + "/wfs?service=wfs&version=1.1.0&REQUEST=GetFeature" + "&TYPENAME=" + layerName + "&BBOX=" + bbox + (limit == 0 ? "" : "&MAXFEATURES=" + limit) + (format == null ? "" : "&OUTPUTFORMAT=" + format);
}
public static String getWmsUrl(String geoServerUrl, String layerName, String style, String bbox) {
return geoServerUrl + "/wms?service=wms&version=1.1.0" + "&request=GetMap&layers=" + layerName + "&styles=" + (style == null ? "" : style) + "&bbox=" + bbox + "&width=676&height=330&srs=EPSG:4326&format=application/openlayers";
}
public static String getWcsUrl(String geoServerUrl, String layerName, String bbox) {
return geoServerUrl + "/wcs?service=wcs&version=1.0.0" + "&request=GetCoverage&layers=" + layerName + "&CRS=EPSG:4326" + "&bbox=" + bbox + "&width=676&height=330&srs=EPSG:4326&format=geotiff";
}
public static String getWmsNetCDFUrl(String fileUrl, String layerName, String bbox) {
return fileUrl.replace("dodsC", "wms") + "?service=wms&version=1.3.0" + "&request=GetMap&layers=" + layerName + "&bbox=" + bbox + "&styles=&width=676&height=330&srs=EPSG:4326&CRS=EPSG:4326&format=image/png";
}
public static String getWcsNetCDFUrl(String fileUrl, String layerName, String bbox) {
return fileUrl.replace("dodsC", "wcs") + "?service=wcs&version=1.0.0" + "&request=GetCoverage&layers=" + layerName + "&CRS=EPSG:4326" + "&bbox=" + bbox + "&srs=EPSG:4326&format=geotiff";
}
public static String buildBoundingBox(double x1, double y1, double x2, double y2) {
// note: the bounding box is left,lower,right,upper
return (y1 + "," + x1 + "," + y2 + "," + x2);
}
public static String pointToBoundingBox(double x1, double y1, double tolerance) {
// note: the bounding box is left,lower,right,upper
double x11 = x1 - tolerance;
double y11 = y1 - tolerance;
double x22 = x1 + tolerance;
double y22 = y1 + tolerance;
return OGCFormatter.buildBoundingBox(x11, y11, x22, y22);
}
}