#8 Configure the BoundingBox when publishing a layer

Possibility to configure the BBox when publishing a Mosaic.
This commit is contained in:
ETj 2011-05-12 16:49:57 +02:00
parent 4de2db5553
commit 7f94202baa
4 changed files with 79 additions and 23 deletions

View File

@ -422,13 +422,38 @@ public class GeoServerRESTPublisher {
* @param workspace an existing workspace
* @param storeName the name of the coverageStore to be created
* @param mosaicDir the directory where the raster images are located
* @param srs the coverage declared SRS
* @param defaultStyle may be null
*
* @return true if the operation completed successfully.
*
* @throws FileNotFoundException
*
* @deprecated work in progress
*/
public RESTCoverageStore publishExternalMosaic(String workspace, String storeName, File mosaicDir, String srs, String defaultStyle) throws FileNotFoundException {
GSCoverageEncoder coverageEncoder = new GSCoverageEncoder();
coverageEncoder.setSRS(srs);
return publishExternalMosaic(workspace, storeName, mosaicDir, coverageEncoder, defaultStyle);
}
/**
* Publish a Mosaic already in a filesystem readable by GeoServer.
*
* <P> Sample cUrl usage:<BR>
* <TT>curl -u admin:geoserver -XPUT -H 'Content-type: text' -d "file:$ABSPORTDIR"
* http://$GSIP:$GSPORT/$SERVLET/rest/workspaces/$WORKSPACE/coveragestores/$BAREDIR/external.imagemosaic </TT>
*
* @param workspace an existing workspace
* @param storeName the name of the coverageStore to be created
* @param mosaicDir the directory where the raster images are located
* @param coverageEncoder the set of parameters to be set to the coverage
* @param defaultStyle may be null
*
* @return true if the operation completed successfully.
*
* @throws FileNotFoundException
*/
public RESTCoverageStore publishExternalMosaic(String workspace, String storeName, File mosaicDir, GSCoverageEncoder coverageEncoder, String defaultStyle) throws FileNotFoundException {
RESTCoverageStore store = configureExternaMosaicDatastore(workspace, storeName, mosaicDir);
if (store != null ) {
try {
@ -440,14 +465,9 @@ public class GeoServerRESTPublisher {
return null;
}
String coverageName = covList.get(0).getName();
// config coverage props (srs)
GSCoverageEncoder coverageEncoder = new GSCoverageEncoder();
coverageEncoder.setSRS(srs);
configureCoverage(coverageEncoder, workspace, storeName, coverageName);
// config layer props (style, ...)
GSLayerEncoder layerEncoder = new GSLayerEncoder();
layerEncoder.setDefaultStyle(defaultStyle);

View File

@ -29,14 +29,10 @@ package it.geosolutions.geoserver.rest.encoder;
*
* @author ETj (etj at geo-solutions.it)
*/
public class GSCoverageEncoder extends PropertyXMLEncoder {
public class GSCoverageEncoder extends GSResourceEncoder {
public GSCoverageEncoder() {
super("coverage");
set("enabled", "true");
}
public void setSRS(String srs) {
setOrRemove("srs", srs);
}
}

View File

@ -29,7 +29,7 @@ package it.geosolutions.geoserver.rest.encoder;
*
* @author ETj (etj at geo-solutions.it)
*/
public class GSFeatureTypeEncoder extends PropertyXMLEncoder {
public class GSFeatureTypeEncoder extends GSResourceEncoder {
public GSFeatureTypeEncoder() {
super("featureType");
@ -38,14 +38,5 @@ public class GSFeatureTypeEncoder extends PropertyXMLEncoder {
public void setName(String name) {
setOrRemove("name", name);
}
public void setSRS(String srs) {
setOrRemove("srs", srs);
}
// public void setNativeCRS(String crs) {
// setOrRemove("nativeCRS", crs);
// }
}
}

View File

@ -0,0 +1,49 @@
/*
* GeoServer-Manager - Simple Manager Library for GeoServer
*
* Copyright (C) 2007,2011 GeoSolutions S.A.S.
* http://www.geo-solutions.it
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package it.geosolutions.geoserver.rest.encoder;
/**
*
* @author ETj (etj at geo-solutions.it)
*/
public abstract class GSResourceEncoder extends PropertyXMLEncoder {
protected GSResourceEncoder(String rootName) {
super(rootName);
}
public void setSRS(String srs) {
setOrRemove("srs", srs);
}
public void setLatLonBoundingBox(double minx, double maxy, double maxx, double miny, String crs) {
setOrRemove("latLonBoundingBox/minx", String.valueOf(minx));
setOrRemove("latLonBoundingBox/maxy", String.valueOf(maxy));
setOrRemove("latLonBoundingBox/maxx", String.valueOf(maxx));
setOrRemove("latLonBoundingBox/miny", String.valueOf(miny));
setOrRemove("latLonBoundingBox/crs", crs);
}
}