From 6d9fbac1c19a496e9c2855dbd7b2b3eabfc7c34b Mon Sep 17 00:00:00 2001 From: Oscar Fonts Date: Mon, 25 Jun 2012 18:03:00 +0200 Subject: [PATCH] Allow to set bbox in publishGeoTiff. Closes #6. --- .../rest/GeoServerRESTPublisher.java | 19 ++++++++++++++++++- .../publisher/GeoserverRESTGeoTiffTest.java | 3 ++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java b/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java index d2b0d87..f83ef4e 100644 --- a/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java +++ b/src/main/java/it/geosolutions/geoserver/rest/GeoServerRESTPublisher.java @@ -1323,6 +1323,19 @@ public class GeoServerRESTPublisher { : (NameValuePair[]) null); } + /** + * Same as {@link publishGeoTIFF(String, String, String, File, String, ProjectionPolicy, String, double[])} + * but without the last parameter (bbox). Kept here for backwards compatibility. + * @deprecated + */ + public boolean publishGeoTIFF(String workspace, String storeName, + String resourceName, File geotiff, String srs, + ProjectionPolicy policy, String defaultStyle) + throws FileNotFoundException, IllegalArgumentException { + return publishGeoTIFF(workspace, storeName, resourceName, + geotiff, srs, policy, defaultStyle, null); + } + /** * @see {@link #publishExternalGeoTIFF(String, String, File, String, String, ProjectionPolicy, String)} * @param workspace @@ -1332,13 +1345,14 @@ public class GeoServerRESTPublisher { * @param srs * @param policy * @param defaultStyle + * @param bbox An array of 4 doubles indicating envelope in EPSG:4326. Order is [Xmin, Ymin, Xmax, Ymax] * @return * @throws FileNotFoundException * @throws IllegalArgumentException */ public boolean publishGeoTIFF(String workspace, String storeName, String resourceName, File geotiff, String srs, - ProjectionPolicy policy, String defaultStyle) + ProjectionPolicy policy, String defaultStyle, double[] bbox) throws FileNotFoundException, IllegalArgumentException { if (workspace == null || storeName == null || geotiff == null || resourceName == null || srs == null || policy == null @@ -1360,6 +1374,9 @@ public class GeoServerRESTPublisher { coverageEncoder.setName(resourceName); coverageEncoder.setSRS(srs); coverageEncoder.setProjectionPolicy(policy); + if(bbox != null && bbox.length == 4) { + coverageEncoder.setLatLonBoundingBox(bbox[0], bbox[1], bbox[2], bbox[3], "EPSG:4326"); + } if (!createCoverage(workspace, storeName, coverageEncoder)) { LOGGER.error("Unable to create a coverage store for coverage: " diff --git a/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTGeoTiffTest.java b/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTGeoTiffTest.java index 8fe664c..d518e56 100644 --- a/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTGeoTiffTest.java +++ b/src/test/java/it/geosolutions/geoserver/rest/publisher/GeoserverRESTGeoTiffTest.java @@ -108,7 +108,8 @@ public class GeoserverRESTGeoTiffTest extends GeoserverRESTTest { assertTrue("publish() failed", pub); - pub = publisher.publishGeoTIFF(DEFAULT_WS, storeName+"another_complex", "layername_complex", geotiff, "EPSG:4326", ProjectionPolicy.REPROJECT_TO_DECLARED,"raster"); + double[] bbox = {-103.85, 44.38, -103.62, 44.50}; + pub = publisher.publishGeoTIFF(DEFAULT_WS, storeName+"another_complex", "layername_complex", geotiff, "EPSG:4326", ProjectionPolicy.REPROJECT_TO_DECLARED, "raster", bbox); assertTrue("publish() failed", pub);