/** * Builds a coverage from a geotools grid coverage reader. * * @param customParameters */ public CoverageInfo buildCoverage(GridCoverage2DReader reader, Map customParameters) throws Exception { return buildCoverage(reader, null, customParameters); }
@Test public void testLargeNDMosaic() throws Exception { // build a mosaic with 1025 files (the standard ulimit is 1024) File mosaic = new File("./target/largeMosaic"); try { createTimeMosaic(mosaic, 1025); // now configure a new store based on it Catalog cat = getCatalog(); CatalogBuilder cb = new CatalogBuilder(cat); CoverageStoreInfo store = cb.buildCoverageStore("largeMosaic"); store.setURL(mosaic.getAbsolutePath()); store.setType("ImageMosaic"); cat.add(store); // and configure also the coverage cb.setStore(store); CoverageInfo ci = cb.buildCoverage(); cat.add(ci); cat.getResourcePool().dispose(); } finally { if (mosaic.exists() && mosaic.isDirectory()) { FileUtils.deleteDirectory(mosaic); } } }
/** Builds the default coverage contained in the current store */ public CoverageInfo buildCoverage() throws Exception { return buildCoverage(null); }
@Test public void testMosaicParameters() throws Exception { // build a mosaic with 1025 files (the standard ulimit is 1024) File mosaic = new File("./target/smallMosaic"); try { createTimeMosaic(mosaic, 4); // now configure a new store based on it Catalog cat = getCatalog(); CatalogBuilder cb = new CatalogBuilder(cat); CoverageStoreInfo store = cb.buildCoverageStore("smallMosaic"); store.setURL(mosaic.getAbsolutePath()); store.setType("ImageMosaic"); cat.add(store); // and configure also the coverage cb.setStore(store); CoverageInfo ci = cb.buildCoverage(); cat.add(ci); // check the parameters have the default values assertEquals( String.valueOf(-1), ci.getParameters() .get(ImageMosaicFormat.MAX_ALLOWED_TILES.getName().toString())); assertEquals("", ci.getParameters().get(ImageMosaicFormat.FILTER.getName().toString())); cat.getResourcePool().dispose(); } finally { if (mosaic.exists() && mosaic.isDirectory()) { FileUtils.deleteDirectory(mosaic); } } }
/** Builds the default coverage contained in the current store */ public CoverageInfo buildCoverage(String coverageName) throws Exception { if (store == null || !(store instanceof CoverageStoreInfo)) { throw new IllegalStateException("Coverage store not set."); } CoverageStoreInfo csinfo = (CoverageStoreInfo) store; GridCoverage2DReader reader = (GridCoverage2DReader) catalog.getResourcePool() .getGridCoverageReader(csinfo, GeoTools.getDefaultHints()); if (reader == null) throw new Exception( "Unable to acquire a reader for this coverage with format: " + csinfo.getFormat().getName()); return buildCoverage(reader, coverageName, null); }
@Test public void testDropCoverageStore() throws Exception { // build the store Catalog cat = getCatalog(); CatalogBuilder cb = new CatalogBuilder(cat); CoverageStoreInfo store = cb.buildCoverageStore("dem"); store.setURL(MockData.class.getResource("tazdem.tiff").toExternalForm()); store.setType("GeoTIFF"); cat.add(store); // build the coverage cb.setStore(store); CoverageInfo ci = cb.buildCoverage(); cat.add(ci); // build the layer LayerInfo layer = cb.buildLayer(ci); cat.add(layer); // grab a reader just to inizialize the code ci.getGridCoverage(null, null); ci.getGridCoverageReader(null, GeoTools.getDefaultHints()); // now drop the store CascadeDeleteVisitor visitor = new CascadeDeleteVisitor(cat); visitor.visit(store); // and reload (GEOS-4782 -> BOOM!) getGeoServer().reload(); }
/** * Create a {@link CoverageInfo} * * @param builder * @param storeInfo * @param cinfo * @param name */ private CoverageInfo buildCoverageInfo( CatalogBuilder builder, CoverageStoreInfo storeInfo, CoverageInfo cinfo, String name) throws Exception { Catalog catalog = storeInfo.getCatalog(); // Get a reader from the pool for this Sample CoverageInfo // (we have to pass it down a CoverageView definition) cinfo.setStore(storeInfo); cinfo.getMetadata().put(CoverageView.COVERAGE_VIEW, this); cinfo.setName(name); cinfo.setNativeCoverageName(name); GridCoverage2DReader reader = (GridCoverage2DReader) catalog.getResourcePool().getGridCoverageReader(cinfo, name, null); builder.setStore(storeInfo); return builder.buildCoverage(reader, name, null); }
CoverageInfo coverage = cb.buildCoverage(reader, null); coverage.setStore(null); coverage.setNamespace(null);
CoverageInfo ci = cb.buildCoverage();
CoverageInfo coverage = cb.buildCoverage(reader, null); coverage.setStore(null); coverage.setNamespace(null);
@Test public void testNativeBoundsDefensiveCopy() throws Exception { Catalog cat = getCatalog(); CatalogBuilder cb = new CatalogBuilder(cat); cb.setStore(cat.getCoverageStoreByName(MockData.TASMANIA_DEM.getLocalPart())); CoverageInfo ci = cb.buildCoverage(); // setup the reproject to declared policy, the issue happens only under this condition ReferencedEnvelope nativeBounds = ci.getNativeBoundingBox(); for (ProjectionPolicy pp : ProjectionPolicy.values()) { ci.setProjectionPolicy(pp); ReferencedEnvelope bbox = ci.boundingBox(); assertNotSame(nativeBounds, bbox); } }
@Test public void testInitCoverageSRSLookup_GEOS8973() throws Exception { Catalog cat = getCatalog(); CatalogBuilder cb = new CatalogBuilder(cat); cb.setStore(cat.getCoverageStoreByName(MockData.WORLD.getLocalPart())); CoverageInfo cinfo = cb.buildCoverage(); cinfo.setSRS(null); String wkt = "GEOGCS[\"ED50\",\n" + " DATUM[\"European Datum 1950\",\n" + " SPHEROID[\"International 1924\", 6378388.0, 297.0]],\n" + "PRIMEM[\"Greenwich\", 0.0],\n" + "UNIT[\"degree\", 0.017453292519943295]]"; CoordinateReferenceSystem testCRS = CRS.parseWKT(wkt); cinfo.setNativeCRS(testCRS); cb.initCoverage(cinfo, "srs lookup"); assertEquals("EPSG:4230", cinfo.getSRS()); }
real = cb.buildCoverage(reader, null); } catch (Exception e) { throw new RuntimeException(e);
@Test public void testSingleBandedCoverage() throws Exception { // build a feature type (it's already in the catalog, but we just want to // check it's built as expected // LINES is a feature type with a native SRS, so we want the bounds to be there Catalog cat = getCatalog(); CatalogBuilder cb = new CatalogBuilder(cat); cb.setStore(cat.getCoverageStoreByName(MockData.TASMANIA_DEM.getLocalPart())); CoverageInfo ci = cb.buildCoverage(); // perform basic checks assertEquals(CRS.decode("EPSG:4326", true), ci.getCRS()); assertEquals("EPSG:4326", ci.getSRS()); assertNotNull(ci.getNativeCRS()); assertNotNull(ci.getNativeBoundingBox()); assertNotNull(ci.getLatLonBoundingBox()); // check the coverage dimensions List<CoverageDimensionInfo> dimensions = ci.getDimensions(); assertEquals(1, dimensions.size()); CoverageDimensionInfo dimension = dimensions.get(0); assertEquals("GRAY_INDEX", dimension.getName()); assertEquals(1, dimension.getNullValues().size()); assertEquals(-9999, dimension.getNullValues().get(0), 0d); assertEquals(Double.NEGATIVE_INFINITY, dimension.getRange().getMinimum(), 0d); // Huston, we have a problem here... // assertEquals(9999, dimension.getRange().getMaximum(), 0d); assertNull(dimension.getUnit()); }
@Test public void testMultiBandCoverage() throws Exception { Catalog cat = getCatalog(); CatalogBuilder cb = new CatalogBuilder(cat); cb.setStore(cat.getCoverageStoreByName(MockData.TASMANIA_BM.getLocalPart())); CoverageInfo ci = cb.buildCoverage(); // perform basic checks assertEquals(CRS.decode("EPSG:4326", true), ci.getCRS()); assertEquals("EPSG:4326", ci.getSRS()); assertNotNull(ci.getNativeCRS()); assertNotNull(ci.getNativeBoundingBox()); assertNotNull(ci.getLatLonBoundingBox()); // check the coverage dimensions List<CoverageDimensionInfo> dimensions = ci.getDimensions(); assertEquals(3, dimensions.size()); CoverageDimensionInfo dimension = dimensions.get(0); assertEquals("RED_BAND", dimension.getName()); assertEquals(0, dimension.getNullValues().size()); assertEquals(Double.NEGATIVE_INFINITY, dimension.getRange().getMinimum(), 0d); assertEquals(Double.POSITIVE_INFINITY, dimension.getRange().getMaximum(), 0d); assertEquals("W.m-2.Sr-1", dimension.getUnit()); }
CoverageInfo coverage = null; try { coverage = builder.buildCoverage(reader, coverageName, null);
nativeName, GeoTools.getDefaultHints()); rebuilt = cb.buildCoverage(reader, nativeName, null); } else { rebuilt = cb.buildCoverage(nativeName);
private void configureCoverageInfo( CatalogBuilder builder, CoverageStoreInfo storeInfo, GridCoverage2DReader reader) throws Exception { // coverage read params final Map customParameters = new HashMap(); CoverageInfo cinfo = builder.buildCoverage(reader, customParameters); // get the coverage name String name = reader.getGridCoverageNames()[0]; cinfo.setName(name); cinfo.setNativeCoverageName(name); // add the store getCatalog().add(cinfo); } }
builder.setStore(expandedStore); if (expandedStore instanceof CoverageStoreInfo) { CoverageInfo ci = builder.buildCoverage(resource.getName().getLocalPart()); return builder.buildLayer(ci); } else if (expandedStore instanceof DataStoreInfo) {
CoverageInfo coverageInfo = cb.buildCoverage(layerConfiguration.getLayer()); coverageInfo.setName(layerConfiguration.getLayer()); timeEnableResource(coverageInfo);