cinfo.setStore(csinfo); cinfo.setEnabled(true); cinfo.setNamespace(namespace); cinfo.setNativeCRS(nativeCRS); Integer code = CRS.lookupEpsgCode(nativeCRS, false); if (code != null) { cinfo.setSRS("EPSG:" + code); cinfo.setProjectionPolicy(ProjectionPolicy.REPROJECT_TO_DECLARED); cinfo.setProjectionPolicy(ProjectionPolicy.FORCE_DECLARED); cinfo.setNativeBoundingBox(new ReferencedEnvelope(envelope)); cinfo.setLatLonBoundingBox( new ReferencedEnvelope(CoverageStoreUtils.getWGS84LonLatEnvelope(envelope))); cinfo.setGrid( new GridGeometry2D( originalRange, cinfo.getDimensions().addAll(coverageDimensions); if (specifiedName != null) { cinfo.setName(specifiedName); cinfo.setTitle(specifiedName); cinfo.getKeywords().add(new Keyword(specifiedName)); } else { String name = reader.getGridCoverageNames()[0];
public GridCoverageReader getGridCoverageReader(ProgressListener listener, Hints hints) throws IOException { return delegate.getGridCoverageReader(listener, hints); }
public String getName() { return delegate.getName(); }
if (other.getDefaultInterpolationMethod() != null) return false; } else if (!defaultInterpolationMethod.equals(other.getDefaultInterpolationMethod())) return false; if (dimensions == null) { if (other.getDimensions() != null) return false; } else if (!dimensions.equals(other.getDimensions())) return false; if (grid == null) { if (other.getGrid() != null) return false; } else if (!grid.equals(other.getGrid())) return false; if (interpolationMethods == null) { if (other.getInterpolationMethods() != null) return false; } else if (!interpolationMethods.equals(other.getInterpolationMethods())) return false; if (nativeFormat == null) { if (other.getNativeFormat() != null) return false; } else if (!nativeFormat.equals(other.getNativeFormat())) return false; if (parameters == null) { if (other.getParameters() != null) return false; } else if (!parameters.equals(other.getParameters())) return false; if (requestSRS == null) { if (other.getRequestSRS() != null) return false; } else if (!requestSRS.equals(other.getRequestSRS())) return false; if (responseSRS == null) { if (other.getResponseSRS() != null) return false; } else if (!responseSRS.equals(other.getResponseSRS())) return false; if (supportedFormats == null) { if (other.getSupportedFormats() != null) return false; } else if (!supportedFormats.equals(other.getSupportedFormats())) return false; if (nativeCoverageName == null) { if (other.getNativeCoverageName() != null) return false;
/** * Update the specified {@link CoverageInfo} with the updated {@link CoverageView} stored within * its metadata * * @param name * @param storeInfo * @param builder * @param coverageInfo */ public void updateCoverageInfo( String name, CoverageStoreInfo storeInfo, CatalogBuilder builder, CoverageInfo coverageInfo) throws Exception { Utilities.ensureNonNull("coverageInfo", coverageInfo); // clean up coverage dimensions for the update coverageInfo.getDimensions().clear(); CoverageInfo info = buildCoverageInfo(builder, storeInfo, coverageInfo, name); coverageInfo.getMetadata().put(CoverageView.COVERAGE_VIEW, this); coverageInfo.getDimensions().addAll(info.getDimensions()); }
/** Create a new {@link CoverageInfo} for this {@link CoverageView} */ public CoverageInfo createCoverageInfo( String name, CoverageStoreInfo storeInfo, CatalogBuilder builder) throws Exception { Catalog catalog = storeInfo.getCatalog(); CoverageInfo coverageInfo = catalog.getFactory().createCoverage(); CoverageInfo info = buildCoverageInfo(builder, storeInfo, coverageInfo, name); info.getMetadata().put(CoverageView.COVERAGE_VIEW, this); info.setName(name); info.setNativeCoverageName(name); return info; }
/** * This method returns {@code true} in case we have POSTed a Coverage object with the name only, * as an instance when configuring a new coverage which has just been harvested. * * @param coverage */ private boolean isNewCoverage(CoverageInfo coverage) { return coverage.getName() != null && (coverage.isAdvertised()) && (!coverage.isEnabled()) && (coverage.getAlias() == null) && (coverage.getCRS() == null) && (coverage.getDefaultInterpolationMethod() == null) && (coverage.getDescription() == null) && (coverage.getDimensions() == null) && (coverage.getGrid() == null) && (coverage.getInterpolationMethods() == null) && (coverage.getKeywords() == null) && (coverage.getLatLonBoundingBox() == null) && (coverage.getMetadata() == null) && (coverage.getNativeBoundingBox() == null) && (coverage.getNativeCRS() == null) && (coverage.getNativeFormat() == null) && (coverage.getProjectionPolicy() == null) && (coverage.getSRS() == null) && (coverage.getResponseSRS() == null) && (coverage.getRequestSRS() == null); }
CatalogFactory cFactory = catalog.getFactory(); CoverageInfo coverage = cFactory.createCoverage(); MetadataMap metadata = coverage.getMetadata(); coverage.setName("test"); coverage.setEnabled(true); coverage.getAlias().add("alias"); coverage.getKeywords().add(new Keyword("key")); MetadataLinkInfoImpl metadataLink = new MetadataLinkInfoImpl(); metadataLink.setAbout("about"); coverage.getMetadataLinks().add(metadataLink); CoverageDimensionImpl coverageDimension = new CoverageDimensionImpl("time"); coverageDimension.setNullValues(Collections.singletonList(new Double(0))); coverage.getDimensions().add(coverageDimension); coverage.getInterpolationMethods().add("Bilinear"); coverage.getParameters().put("ParameterKey", "ParameterValue"); coverage.getSupportedFormats().add("GEOTIFF"); coverage.getRequestSRS().add("EPSG:4326"); coverage.getResponseSRS().add("EPSG:4326");
cv.setStore(cs); cv.setNamespace(ns); cv.setName("cv"); cv.setAbstract("abstract"); cv.setSRS("EPSG:4326"); cv.setNativeCRS(CRS.decode("EPSG:4326")); cv.getParameters().put("foo", null); assertNotNull(cv); assertEquals("cv", cv.getName()); assertEquals(cs, cv.getStore()); assertEquals(ns, cv.getNamespace()); assertEquals("EPSG:4326", cv.getSRS()); assertTrue(cv.getParameters().containsKey("foo")); assertNull(cv.getParameters().get("foo")); assertTrue(CRS.equalsIgnoreMetadata(CRS.decode("EPSG:4326"), cv.getNativeCRS()));
srs = real.getSRS(); ns, srs, real.getProjectionPolicy(), real.getNativeBoundingBox(), real.getLatLonBoundingBox()); expect(c.getDefaultInterpolationMethod()) .andReturn(real.getDefaultInterpolationMethod()) .anyTimes(); expect(c.getDimensions()).andReturn(real.getDimensions()).anyTimes(); expect(c.getGrid()).andReturn(real.getGrid()).anyTimes(); expect(c.getInterpolationMethods()).andReturn(real.getInterpolationMethods()).anyTimes(); expect(c.getRequestSRS()).andReturn(real.getRequestSRS()).anyTimes(); expect(c.getResponseSRS()).andReturn(real.getResponseSRS()).anyTimes(); expect(c.getGridCoverageReader(null, null)).andReturn(reader).anyTimes(); } catch (IOException e) { expect(catalog.getCoverageByCoverageStore(cs, name)).andReturn(c).anyTimes(); c.accept((CatalogVisitor) anyObject()); expectLastCall() .andAnswer(
public static CoverageInfo localizeCoverage(final CoverageInfo info, final Catalog catalog) throws IllegalAccessException, InvocationTargetException { if (info==null || catalog==null) throw new NullArgumentException("Arguments may never be null"); final CoverageInfo localObject=catalog.getCoverageByName(info.getNamespace(),info.getName()); if (localObject !=null){ return localObject; } final CoverageInfo createdObject = catalog.getFactory().createCoverage(); // let's using the created object (see getGridCoverageReader) BeanUtils.copyProperties(createdObject, info); createdObject.setNamespace(localizeNamespace(info.getNamespace(), catalog)); createdObject.setStore(localizeCoverageStore(info.getStore(), catalog)); final CatalogBuilder builder = new CatalogBuilder(catalog); builder.attach(createdObject); return createdObject; }
cv.setStore(cs); cv.setNamespace(ns); cv.setName("coverage"); cv.setAbstract("abstract"); cv.setSRS("EPSG:4326"); cv.setNativeCRS(CRS.decode("EPSG:4326")); cv.getParameters().put("foo", null); cv = persister.load(in, CoverageInfo.class); assertNotNull(cv); assertNotNull(cv.getGrid()); assertNotNull(cv.getGrid().getGridRange()); assertNotNull(cv.getCRS()); assertNotNull(cv.getGrid().getGridToCRS()); assertEquals(cv.getGrid().getGridRange().getLow(0), 0);
@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()); }
if (cinfo.getNativeCRS() == null) { cinfo.setNativeCRS(reader.getCoordinateReferenceSystem()); CoordinateReferenceSystem nativeCRS = cinfo.getNativeCRS(); Integer code = CRS.lookupEpsgCode(nativeCRS, false); if (code != null) { cinfo.setSRS("EPSG:" + code); cinfo.setProjectionPolicy(ProjectionPolicy.FORCE_DECLARED); if (cinfo.getProjectionPolicy() == null) { if (nativeCRS != null && !nativeCRS.getIdentifiers().isEmpty()) { cinfo.setProjectionPolicy(ProjectionPolicy.REPROJECT_TO_DECLARED); cinfo.setProjectionPolicy(ProjectionPolicy.FORCE_DECLARED); if (cinfo.getLatLonBoundingBox() == null && cinfo.getNativeBoundingBox() == null) { GeneralEnvelope envelope = reader.getOriginalEnvelope(); cinfo.setNativeBoundingBox(new ReferencedEnvelope(envelope)); cinfo.setLatLonBoundingBox( new ReferencedEnvelope(CoverageStoreUtils.getWGS84LonLatEnvelope(envelope))); } else if (cinfo.getLatLonBoundingBox() == null) { setupBounds(cinfo); } else if (cinfo.getNativeBoundingBox() == null && cinfo.getNativeCRS() != null) { ReferencedEnvelope boundsLatLon = cinfo.getLatLonBoundingBox(); cinfo.setNativeBoundingBox(boundsLatLon.transform(cinfo.getNativeCRS(), true)); if (cinfo.getGrid() == null) {
public MetadataMap getMetadata() { return delegate.getMetadata(); }
/** * Grabs the reader from the specified coverage * * @param ci * @throws IOException */ public static GridCoverage2DReader getCoverageReader(CoverageInfo ci) throws IOException, Exception { // get a reader for this coverage final CoverageStoreInfo store = (CoverageStoreInfo) ci.getStore(); final GridCoverageReader reader_ = ci.getGridCoverageReader(new DefaultProgressListener(), GeoTools.getDefaultHints()); if (reader_ == null) { throw new Exception( "Unable to acquire a reader for this coverage with format: " + store.getFormat().getName()); } final GridCoverage2DReader reader = (GridCoverage2DReader) reader_; return reader; }
/** * 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); }
Boolean dataset = ci.getMetadata().get(WCSEOMetadata.DATASET.key, Boolean.class); DimensionInfo time = ci.getMetadata().get(ResourceInfo.TIME, DimensionInfo.class); if (dataset != null && dataset && time != null && time.isEnabled()) { tx.start("wcseo:DatasetSeriesSummary"); ReferencedEnvelope bbox = ci.getLatLonBoundingBox(); tx.start("ows:WGS84BoundingBox"); element(tx, "ows:LowerCorner", bbox.getMinX() + " " + bbox.getMinY(), null); (GridCoverage2DReader) ci.getGridCoverageReader(null, null);
coverageInfo.getParameters().put("USE_JAI_IMAGEREAD", "false"); cat.add(coverageInfo); final MetadataMap metadata = coverageInfo.getMetadata(); final CoverageView metadataCoverageView = (CoverageView) metadata.get(CoverageView.COVERAGE_VIEW); final ReferencedEnvelope bbox = coverageInfo.getLatLonBoundingBox(); final GridCoverage coverage = resPool.getGridCoverage(coverageInfo, "waterView", bbox, null);
protected void handleCoverageDescription(CoverageInfo ci) throws Exception { start("wcs:CoverageDescription"); element("ows:Title", ci.getTitle()); element("ows:Abstract", ci.getDescription()); handleKeywords(ci.getKeywords()); element("wcs:Identifier", ci.getStore().getWorkspace().getName() + ":" + ci.getName()); handleMetadataLinks(ci.getMetadataLinks(), "simple"); handleDomain(ci); handleRange(ci); handleSupportedCRSs(ci); handleSupportedFormats(ci); end("wcs:CoverageDescription"); }