+ String bboxStr = getKvpParameter(parameters, BBOX);
+ log.debug(bboxStr);
+ final Envelope bbox;
+ if (bboxStr != null) {
+ String srs;
+ String[] arr = bboxStr.split(",");
+ // TODO check SRS and convert to WGS84
+ double minLat = Double.parseDouble(arr[0]);
+ double minLon = Double.parseDouble(arr[1]);
+ double maxLat = Double.parseDouble(arr[2]);
+ double maxLon = Double.parseDouble(arr[3]);
+ if (arr.length == 5) {
+ srs = arr[4];
+ } else {
+ srs = null;
+ }
+
+ if (srs != null) {
+ try {
+ CoordinateReferenceSystem sourceCRS = CRS.decode(srs);
+ CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:4326");
+ MathTransform transform = CRS.findMathTransform(sourceCRS, targetCRS, true);
+ bbox = org.geotools.geometry.jts.JTS.transform(
+ new Envelope(new Coordinate(minLat, minLon), new Coordinate(maxLat, maxLon)), transform);
+ } catch (FactoryException | TransformException e) {
+ throw new IllegalArgumentException("Cannot convert bounding box", e);
+ // bbox = null;
+ }
+ } else {
+ bbox = new Envelope(new Coordinate(minLat, minLon), new Coordinate(maxLat, maxLon));
+ }
+ } else {
+ bbox = null;
+ }