public static GridCoverage2D wrapCoverage( GridCoverage2D coverage, GridCoverage2D sourceCoverage, GridSampleDimension[] wrappedDimensions, Map properties, boolean forceWrapping) { if (coverage instanceof GridCoverageWrapper || forceWrapping) { return new GridCoverageWrapper( coverage.getName().toString(), coverage, wrappedDimensions == null ? coverage.getSampleDimensions() : wrappedDimensions, properties == null ? sourceCoverage.getProperties() : properties); } return coverage; }
public DisposableGridCoverage(GridCoverage2D coverage) { super(coverage.getName(), coverage); delegate = coverage; // wrappedPropertySource = new PropertySourceImpl( // Collections.singletonMap("disposable", true), // coverage instanceof PropertySource ? (PropertySource) coverage : null); }
/** * Constructs a new grid coverage for the specified grid geometry. * * @param source The source for this grid coverage. * @param image The image. * @param geometry The grid geometry (including the new CRS). * @param sampleDimensions The sample dimensions to be given to the new coverage. */ private Resampler2D( final GridCoverage2D source, final PlanarImage image, final GridGeometry2D geometry, final GridSampleDimension[] sampleDimensions, final Map<String, Serializable> properties, final Hints hints) { super( source.getName(), image, geometry, sampleDimensions, new GridCoverage2D[] {source}, properties, hints); }
/** * The BandMerge operation takes indexed images and expands them, however in the context of * coverage view band merging we don't normally want that, e.g., raster mask bands are * represented as indexed but we really want to keep them in their binary, single band form. To * do so, the IndexColorModel is replaced by a ComponentColorModel * * @param coverage * @return */ private GridCoverage2D prepareForBandMerge(GridCoverage2D coverage) { RenderedImage ri = coverage.getRenderedImage(); SampleModel sampleModel = ri.getSampleModel(); if (sampleModel.getNumBands() == 1 && ri.getColorModel() instanceof IndexColorModel) { ImageWorker worker = new ImageWorker(ri); worker.removeIndexColorModel(); RenderedImage formatted = worker.getRenderedImage(); return new GridCoverageFactory() .create( coverage.getName(), formatted, coverage.getGridGeometry(), coverage.getSampleDimensions(), new GridCoverage[] {coverage}, coverage.getProperties()); } return coverage; }
/** * Returns a name for the target {@linkplain GridCoverage2D grid coverage} based on the given * sources. This method is invoked once by the {@link #deriveGridCoverage deriveGridCoverage} * method. The default implementation returns the operation name followed by the source name * between parenthesis, for example "<cite>Add(Sea Surface Temperature)</cite>". * * @param sources The sources grid coverage. * @param primarySourceIndex The index of what seems to be the primary source, or {@code -1} if * none of unknown. * @param parameters Parameters, rendering hints and coordinate reference system to use. * @return A name for the target grid coverage. */ protected InternationalString deriveName( final GridCoverage2D[] sources, final int primarySourceIndex, final Parameters parameters) { final InternationalString[] names; if (primarySourceIndex >= 0) { names = new InternationalString[] {sources[primarySourceIndex].getName()}; } else { names = new InternationalString[sources.length]; for (int i = 0; i < names.length; i++) { if (sources[i] != null) names[i] = sources[i].getName(); } } return new Name(getName(), names); }
/** {inheritDoc} */ @Override public void show(String title, final int xAxis, final int yAxis) { if (title == null || (title = title.trim()).length() == 0) { final StringBuilder buffer = new StringBuilder(String.valueOf(getName())); final int visibleBandIndex = CoverageUtilities.getVisibleBand(this); final SampleDimension visibleBand = getSampleDimension(visibleBandIndex); final Unit<?> unit = visibleBand.getUnits(); buffer.append(" - ").append(String.valueOf(visibleBand.getDescription())); if (unit != null) { buffer.append(" (").append(unit).append(')'); } title = buffer.toString(); } super.show(title, xAxis, yAxis); }
Level.FINE, LoggingKeys.CREATED_SERIALIZABLE_IMAGE_$2, getName(), tileEncoding); record.setSourceClassName(GridCoverage2D.class.getName());
/** * Constructs a new {@code BandSelect2D} grid coverage. This grid coverage will use the same * coordinate reference system and the same geometry than the source grid coverage. * * @param source The source coverage. * @param image The image to use. * @param bands The sample dimensions to use. * @param bandIndices The mapping to bands in {@code source}. Not used by this constructor, but * keept for futur reference. * @todo It would be nice if we could use always the "BandSelect" operation without the "Null" * one. But as of JAI-1.1.1, "BandSelect" do not detect by itself the case were no copy is * required. */ private BandSelector2D( final GridCoverage2D source, final PlanarImage image, final GridSampleDimension[] bands, final int[] bandIndices, final Hints hints) { super( source.getName(), // The grid source name image, // The underlying data source.getGridGeometry(), // The grid geometry (unchanged). bands, // The sample dimensions new GridCoverage2D[] {source}, // The source grid coverages. source.getProperties(), hints); // Properties this.bandIndices = bandIndices; assert bandIndices == null || bandIndices.length == bands.length; }
result.getName(), result.getRenderedImage(), result.getEnvelope());
properties.put("GC_ROI", roi); return gridCoverageFactory.create( coverage.getName(), pi, coverage.getGridGeometry(),
static GridCoverage2D displace( GridCoverage2D coverage, double tx, double ty, GridCoverageFactory gridCoverageFactory) { // let's compute the new grid geometry GridGeometry2D originalGG = coverage.getGridGeometry(); GridEnvelope gridRange = originalGG.getGridRange(); Envelope2D envelope = originalGG.getEnvelope2D(); double minx = envelope.getMinX() + tx; double miny = envelope.getMinY() + ty; double maxx = envelope.getMaxX() + tx; double maxy = envelope.getMaxY() + ty; ReferencedEnvelope translatedEnvelope = new ReferencedEnvelope( minx, maxx, miny, maxy, envelope.getCoordinateReferenceSystem()); GridGeometry2D translatedGG = new GridGeometry2D(gridRange, translatedEnvelope); GridCoverage2D translatedCoverage = gridCoverageFactory.create( coverage.getName(), coverage.getRenderedImage(), translatedGG, coverage.getSampleDimensions(), new GridCoverage2D[] {coverage}, coverage.getProperties()); return translatedCoverage; }
source.getName().toString(), gridCoverageImage, (GridGeometry2D) source.getGridGeometry(),
input.getName(), im, new GridGeometry2D(
ftBuilder.setName(gc2d.getName().toString()); ftBuilder.setNamespaceURI("http://www.geotools.org/");
@Override public GridCoverage2D read(GeneralParameterValue[] parameters) throws IOException { GridCoverage2D originalCoverage = super.read(parameters); RenderedImage source = new ImageWorker(originalCoverage.getRenderedImage()) .format(DataBuffer.TYPE_USHORT) .getRenderedImage(); TiledImage shortImage = new TiledImage( source.getMinX(), source.getMinY(), source.getWidth(), source.getHeight(), source.getTileGridXOffset(), source.getTileGridYOffset(), source.getSampleModel(), null); shortImage.set(source); // force color model to be null, this also occurs in real cases GridCoverage2D coverage = CoverageFactoryFinder.getGridCoverageFactory(null) .create( originalCoverage.getName(), shortImage, originalCoverage.getEnvelope2D()); return coverage; } };
CoverageFactoryFinder.getGridCoverageFactory(GeoTools.getDefaultHints()) .create( visual.getName(), newImage, visual.getCoordinateReferenceSystem2D(),
Errors.format(ErrorKeys.CANT_REPROJECT_$1, source.getName()), exception);
"color_mapped_" + sourceCoverage.getName().toString(), classified, sourceCoverage.getGridGeometry(),