-
Notifications
You must be signed in to change notification settings - Fork 193
Managing Mosaic Layers
Carlo Cancellieri edited this page Mar 21, 2014
·
14 revisions
The following code will create an external coverage store in GeoServer also publishing the layer:
// layer encoder
final GSLayerEncoder layerEnc = new GSLayerEncoder();
String style=getDefaultStyle();
if (style==null || style.isEmpty())
style="raster";
layerEnc.setDefaultStyle(style);
// coverage encoder
final GSImageMosaicEncoder coverageEnc=new GSImageMosaicEncoder();
coverageEnc.setName(mosaicDescriptor.getCoverageStoreId());
coverageEnc.setTitle(mosaicDescriptor.getCoverageStoreId());
if (config.getCrs()!=null){
coverageEnc.setSRS(config.getCrs());
}
coverageEnc.setMaxAllowedTiles(Integer.MAX_VALUE);
// ... many other options are supported
// create a new ImageMosaic layer...
final boolean published = gsPublisher.publishExternalMosaic(workspace, storeName, baseDir, coverageEnc, layerEnc);
// check the results
if (!published) {
final String msg="Error creating the new store: " + layerName;
Exception ex = new Exception(this.getClass(), msg);
}
Example about how to manage an ImageMosaic from REST with sample data (GeoServer >= 2.4.0 and GeoServer-Manager >= 2.6.0)
The code is taken from a test-case that does configure a small ImageMosaic with custom dimensions. Check the internal comments for more information, the code is quite documented.
The test data and the mosaic configuration used in the example can be found here.
The link to the live code can be found here
Notice that GeoServer-Manager supports the CQL syntax for querying the granules of a mosaic. Documentation about such syntax can be found at the following links:
Advanced queries for getting Granules from an ImageMosaic (GeoServer >= 2.4.0 and GeoServer-Manager >= 1.6.0)
Here below you can find some additional examples on how to query an ImageMosaic index.
granulesList = manager.getGranules(workspaceName, coverageStoreName, coverageName, "location ILIKE '%data%'", null, null);
assertNotNull(granulesList);
granulesList = manager.getGranules(workspaceName, coverageStoreName, coverageName, "time BEFORE 2013-06-28T22:00:00Z", null, null);
assertNotNull(granulesList);
or
granulesList = manager.getGranules(workspaceName, coverageStoreName, coverageName, "time <= 2013-06-28T22:00:00Z", null, null);
assertNotNull(granulesList);
granulesList = manager.getGranules(workspaceName, coverageStoreName, coverageName, "time <= 2013-06-28T22:00:00Z AND time >=2011-01-01T00:00:00Z", null, null);
assertNotNull(granulesList);
or
granulesList = manager.getGranules(workspaceName, coverageStoreName, coverageName, "time DURING 2011-01-01T00:00:00Z/2013-06-28T22:00:00Z", null, null);
assertNotNull(granulesList);