当前位置: 首页>>代码示例>>Java>>正文


Java GridCoverageFactory类代码示例

本文整理汇总了Java中org.geotools.coverage.grid.GridCoverageFactory的典型用法代码示例。如果您正苦于以下问题:Java GridCoverageFactory类的具体用法?Java GridCoverageFactory怎么用?Java GridCoverageFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GridCoverageFactory类属于org.geotools.coverage.grid包,在下文中一共展示了GridCoverageFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import org.geotools.coverage.grid.GridCoverageFactory; //导入依赖的package包/类
@DescribeResult(name = "result", description = "This is just a pass-through, the key is to provide enough information within invertQuery to perform a map to screen transform")
public GridCoverage2D execute(
		@DescribeParameter(name = "data", description = "Feature collection containing the rendered image")
		final SimpleFeatureCollection features )
		throws ProcessException {
	// vector-to-raster render transform that take a single feature that
	// wraps a distributed render result and converts it to a GridCoverage2D
	if (features != null) {
		final SimpleFeatureIterator it = features.features();
		if (it.hasNext()) {
			final SimpleFeature resultFeature = features.features().next();
			final DistributedRenderResult actualResult = (DistributedRenderResult) resultFeature.getAttribute(0);
			final DistributedRenderOptions renderOptions = (DistributedRenderOptions) resultFeature.getAttribute(1);
			// convert to the GridCoverage2D required for output
			final GridCoverageFactory gcf = CoverageFactoryFinder
					.getGridCoverageFactory(GeoTools.getDefaultHints());
			final BufferedImage result = actualResult.renderComposite(renderOptions);
			final GridCoverage2D gridCov = gcf.create(
					"Process Results",
					result,
					renderOptions.getEnvelope());
			return gridCov;
		}
	}
	return null;
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:27,代码来源:InternalDistributedRenderProcess.java

示例2: testExactUpScale

import org.geotools.coverage.grid.GridCoverageFactory; //导入依赖的package包/类
@Test
public void testExactUpScale() {
    float[][] grid = new float[][] {{1,2},{3,4}};
    final GridCoverageFactory coverageFactory = CoverageFactoryFinder.getGridCoverageFactory(GeoTools.getDefaultHints());
    final GridCoverage2D coverage = coverageFactory.create("geohashGridAgg", grid, new ReferencedEnvelope(0,1,0,1,null));
    GridCoverage2D scaled = GridCoverageUtil.scale(coverage, 4, 4);
    final RenderedImage renderedImage = scaled.getRenderedImage();
    assertEquals(4, renderedImage.getWidth());
    assertEquals(4, renderedImage.getHeight());
    float[][] expected = new float[][] {{1,1,2,2},{1,1,2,2},{3,3,4,4},{3,3,4,4}};
    IntStream.range(0,4).forEach(i->IntStream.range(0, 4).forEach(j -> {
        float actual = scaled.evaluate(new GridCoordinates2D(j,i), new float[1])[0];
        assertEquals(expected[i][j], actual, 1e-10);
    }));
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:16,代码来源:GridCoverageUtilTest.java

示例3: testExactDownScale

import org.geotools.coverage.grid.GridCoverageFactory; //导入依赖的package包/类
@Test
public void testExactDownScale() {
    float[][] grid = new float[][] {{1,1,2,2},{1,1,2,2},{3,3,4,4},{3,3,4,4}};
    final GridCoverageFactory coverageFactory = CoverageFactoryFinder.getGridCoverageFactory(GeoTools.getDefaultHints());
    final GridCoverage2D coverage = coverageFactory.create("geohashGridAgg", grid, new ReferencedEnvelope(0,1,0,1,null));
    GridCoverage2D scaled = GridCoverageUtil.scale(coverage, 2,2);
    final RenderedImage renderedImage = scaled.getRenderedImage();
    assertEquals(2, renderedImage.getWidth());
    assertEquals(2, renderedImage.getHeight());
    float[][] expected = new float[][] {{1,2},{3,4}};
    IntStream.range(0,2).forEach(i->IntStream.range(0, 2).forEach(j -> {
        float actual = scaled.evaluate(new GridCoordinates2D(j,i), new float[1])[0];
        assertEquals(expected[i][j], actual, 1e-10);
    }));
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:16,代码来源:GridCoverageUtilTest.java

示例4: testInexactScale

import org.geotools.coverage.grid.GridCoverageFactory; //导入依赖的package包/类
@Test
public void testInexactScale() {
    float[][] grid = new float[][] {{1,2},{3,4}};
    final GridCoverageFactory coverageFactory = CoverageFactoryFinder.getGridCoverageFactory(GeoTools.getDefaultHints());
    final GridCoverage2D coverage = coverageFactory.create("geohashGridAgg", grid, new ReferencedEnvelope(0,1,0,1,null));
    GridCoverage2D scaled = GridCoverageUtil.scale(coverage, 3, 7);
    final RenderedImage renderedImage = scaled.getRenderedImage();
    assertEquals(7, renderedImage.getWidth());
    assertEquals(3, renderedImage.getHeight());
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:11,代码来源:GridCoverageUtilTest.java

示例5: testSmallScale

import org.geotools.coverage.grid.GridCoverageFactory; //导入依赖的package包/类
@Test
public void testSmallScale() {
    float[][] grid = new float[1500][1500];
    final GridCoverageFactory coverageFactory = CoverageFactoryFinder.getGridCoverageFactory(GeoTools.getDefaultHints());
    final GridCoverage2D coverage = coverageFactory.create("geohashGridAgg", grid, new ReferencedEnvelope(0,1,0,1,null));
    GridCoverage2D scaled = GridCoverageUtil.scale(coverage, 1501, 1499);
    final RenderedImage renderedImage = scaled.getRenderedImage();
    assertEquals(1499, renderedImage.getWidth());
    assertEquals(1501, renderedImage.getHeight());
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:11,代码来源:GridCoverageUtilTest.java

示例6: testLargeScale

import org.geotools.coverage.grid.GridCoverageFactory; //导入依赖的package包/类
@Test
public void testLargeScale() {
    float[][] grid = new float[2][2];
    final GridCoverageFactory coverageFactory = CoverageFactoryFinder.getGridCoverageFactory(GeoTools.getDefaultHints());
    final GridCoverage2D coverage = coverageFactory.create("geohashGridAgg", grid, new ReferencedEnvelope(0,1,0,1,null));
    GridCoverage2D scaled = GridCoverageUtil.scale(coverage, 1501, 1499);
    final RenderedImage renderedImage = scaled.getRenderedImage();
    assertEquals(1499, renderedImage.getWidth());
    assertEquals(1501, renderedImage.getHeight());
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:11,代码来源:GridCoverageUtilTest.java

示例7: testCrop

import org.geotools.coverage.grid.GridCoverageFactory; //导入依赖的package包/类
@Test
public void testCrop() throws MismatchedDimensionException, NoSuchAuthorityCodeException, FactoryException {
    float[][] grid = new float[][] {{3,4},{1,2}};
    final GridCoverageFactory coverageFactory = CoverageFactoryFinder.getGridCoverageFactory(GeoTools.getDefaultHints());
    final GridCoverage2D coverage = coverageFactory.create("geohashGridAgg", grid, new ReferencedEnvelope(0,20,0,20,null));
    final ReferencedEnvelope envelope = new ReferencedEnvelope(10,20,10,20,null);
    final GridCoverage2D croppedCoverage = GridCoverageUtil.crop(coverage, envelope);
    final RenderedImage renderedImage = croppedCoverage.getRenderedImage();
    assertEquals(1, renderedImage.getWidth());
    assertEquals(1, renderedImage.getHeight());
    assertEquals(4, croppedCoverage.evaluate(new Point2D.Double(15,15), new float[1])[0], 1e-10);
}
 
开发者ID:ngageoint,项目名称:elasticgeo,代码行数:13,代码来源:GridCoverageUtilTest.java

示例8: createCoverage

import org.geotools.coverage.grid.GridCoverageFactory; //导入依赖的package包/类
/**
 * Creates the
 *
 * @param data
 * @return
 */
public GridCoverage2D createCoverage(float[] data, int columns, int rows) {
  GridCoverageFactory gcf = CoverageFactoryFinder.getGridCoverageFactory(null);
  TiledImage img = ceateImageContent(data, columns, rows);
  ReferencedEnvelope env = createEnvelope();
  return gcf.create("coverage", img, env);
}
 
开发者ID:MeteoGroup,项目名称:grib2geotiff,代码行数:13,代码来源:GeoTiffExporter.java

示例9: testSimpleScript2ImagesCombined

import org.geotools.coverage.grid.GridCoverageFactory; //导入依赖的package包/类
@Test
public void testSimpleScript2ImagesCombined() throws Exception {

    if (testCoverage1 != null && testCoverage2 != null) {
        // Script selection
        String script = FileUtils.readFileToString(new File(JIFFLE_SCRIPT_PATH));
        // Combination of the bands of the 2 images
        RenderedImage img1 = testCoverage1.getRenderedImage();
        RenderedImage img2 = testCoverage2.getRenderedImage();

        RenderedImage imgComposed = BandMergeDescriptor.create(img1, img2, hints);

        GridCoverage2D composedCoverage = new GridCoverageFactory(null).create("New_cov",
                imgComposed, testCoverage1.getGridGeometry().getEnvelope());
        // Process calculation
        GridCoverage2D finalCoverage = process.execute(composedCoverage, script, null, 0);
        // Check the result
        assertNotNull(finalCoverage);

        RenderedImage finalImage = finalCoverage.getRenderedImage();

        assertEquals(finalImage.getSampleModel().getNumBands(), FINAL_NUM_BANDS);

        PlanarImage.wrapRenderedImage(finalImage).getTiles();

        checkExecution(finalImage, FINAL_VALUES, testCoverage1, testCoverage2);

        finalCoverage.dispose(true);
        if (finalImage instanceof RenderedOp) {
            ((RenderedOp) finalImage).dispose();
        }
    } else {
        LOGGER.log(
                Level.WARNING,
                "\nTest2: files not found in geoserver-enterprise/src/extension/wps/wps-core/src/test/java/org/geoserver/wps/raster/algebra");
    }
}
 
开发者ID:geosolutions-it,项目名称:soil_sealing,代码行数:38,代码来源:JiffleScriptProcessTest.java

示例10: createCoverageFromTemplate

import org.geotools.coverage.grid.GridCoverageFactory; //导入依赖的package包/类
/**
 * Creates a new {@link GridCoverage2D} using an existing as template.
 * 
 * @param template the template to use.
 * @param value the value to set the new raster to, if not <code>null</code>.
 * @param writableRasterHolder an array of length 1 to place the writable raster in, that 
 *                  was can be used to populate the coverage. If <code>null</code>, it is ignored.
 * @return the new coverage.
 */
public static GridCoverage2D createCoverageFromTemplate( GridCoverage2D template, Double value,
        WritableRaster[] writableRasterHolder ) {
    RegionMap regionMap = getRegionParamsFromGridCoverage(template);

    double west = regionMap.getWest();
    double south = regionMap.getSouth();
    double east = regionMap.getEast();
    double north = regionMap.getNorth();
    int cols = regionMap.getCols();
    int rows = regionMap.getRows();
    ComponentSampleModel sampleModel = new ComponentSampleModel(DataBuffer.TYPE_DOUBLE, cols, rows, 1, cols, new int[]{0});

    WritableRaster raster = RasterFactory.createWritableRaster(sampleModel, null);
    if (value != null) {
        // autobox only once
        double v = value;
        for( int y = 0; y < rows; y++ ) {
            for( int x = 0; x < cols; x++ ) {
                raster.setSample(x, y, 0, v);
            }
        }
    }
    if (writableRasterHolder != null) {
        writableRasterHolder[0] = raster;
    }

    Envelope2D writeEnvelope = new Envelope2D(template.getCoordinateReferenceSystem(), west, south, east - west,
            north - south);
    GridCoverageFactory factory = CoverageFactoryFinder.getGridCoverageFactory(null);
    GridCoverage2D coverage2D = factory.create("newraster", raster, writeEnvelope);
    return coverage2D;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:42,代码来源:CoverageUtilities.java

示例11: createSubCoverageFromTemplate

import org.geotools.coverage.grid.GridCoverageFactory; //导入依赖的package包/类
/**
 * Create a subcoverage given a template coverage and an envelope.
 * 
 * @param template the template coverage used for the resolution.
 * @param subregion the envelope to extract to the new coverage. This should
 *                  be snapped on the resolution of the coverage, in order to avoid 
 *                  shifts.
 * @param value the value to set the new raster to, if not <code>null</code>. 
 * @param writableRasterHolder an array of length 1 to place the writable raster in, that 
 *                  was can be used to populate the coverage. If <code>null</code>, it is ignored.
 * @return the new coverage.
 */
public static GridCoverage2D createSubCoverageFromTemplate( GridCoverage2D template, Envelope2D subregion, Double value,
        WritableRaster[] writableRasterHolder ) {
    RegionMap regionMap = getRegionParamsFromGridCoverage(template);
    double xRes = regionMap.getXres();
    double yRes = regionMap.getYres();

    double west = subregion.getMinX();
    double south = subregion.getMinY();
    double east = subregion.getMaxX();
    double north = subregion.getMaxY();

    int cols = (int) ((east - west) / xRes);
    int rows = (int) ((north - south) / yRes);
    ComponentSampleModel sampleModel = new ComponentSampleModel(DataBuffer.TYPE_DOUBLE, cols, rows, 1, cols, new int[]{0});

    WritableRaster writableRaster = RasterFactory.createWritableRaster(sampleModel, null);
    if (value != null) {
        // autobox only once
        double v = value;
        for( int y = 0; y < rows; y++ ) {
            for( int x = 0; x < cols; x++ ) {
                writableRaster.setSample(x, y, 0, v);
            }
        }
    }
    if (writableRasterHolder != null)
        writableRasterHolder[0] = writableRaster;
    Envelope2D writeEnvelope = new Envelope2D(template.getCoordinateReferenceSystem(), west, south, east - west,
            north - south);
    GridCoverageFactory factory = CoverageFactoryFinder.getGridCoverageFactory(null);
    GridCoverage2D coverage2D = factory.create("newraster", writableRaster, writeEnvelope);
    return coverage2D;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:46,代码来源:CoverageUtilities.java

示例12: buildCoverage

import org.geotools.coverage.grid.GridCoverageFactory; //导入依赖的package包/类
/**
 * Creates a {@link GridCoverage2D coverage} from the {@link RenderedImage image} and the necessary geographic Information.
 * 
 * @param name the name of the coverage.
 * @param renderedImage the image containing the data.
 * @param envelopeParams the map of boundary parameters.
 * @param crs the {@link CoordinateReferenceSystem}.
 * @return the {@link GridCoverage2D coverage}.
 */
public static GridCoverage2D buildCoverage( String name, RenderedImage renderedImage, HashMap<String, Double> envelopeParams,
        CoordinateReferenceSystem crs ) {

    double west = envelopeParams.get(WEST);
    double south = envelopeParams.get(SOUTH);
    double east = envelopeParams.get(EAST);
    double north = envelopeParams.get(NORTH);
    Envelope2D writeEnvelope = new Envelope2D(crs, west, south, east - west, north - south);
    GridCoverageFactory factory = CoverageFactoryFinder.getGridCoverageFactory(null);

    GridCoverage2D coverage2D = factory.create(name, renderedImage, writeEnvelope);
    return coverage2D;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:23,代码来源:CoverageUtilities.java

示例13: saveRaster

import org.geotools.coverage.grid.GridCoverageFactory; //导入依赖的package包/类
/**
 * Save a set of raster data at a given location.
 * @param location The file location at which to save the raster.
 * @param raster The raw pixel values for the raster.
 * @param extents The extent of the raster.
 * @param properties The meta-data for the raster.
 * @throws IOException thrown if unable to save the raster.
 */
public static void saveRaster(File location, WritableRaster raster,
                              Envelope2D extents, GridSampleDimension[] properties) throws IOException {
    GridCoverage2D targetRaster = null;
    try {
        GridCoverageFactory factory = new GridCoverageFactory();
        targetRaster = factory.create(location.getName(), raster, extents, properties);
        saveRaster(location, targetRaster);
    } finally {
        disposeRaster(targetRaster);
    }
}
 
开发者ID:SEEG-Oxford,项目名称:ABRAID-MP,代码行数:20,代码来源:RasterUtils.java

示例14: exampleGridCoverageFactory

import org.geotools.coverage.grid.GridCoverageFactory; //导入依赖的package包/类
@SuppressWarnings("unused")
void exampleGridCoverageFactory() throws Exception {
    
    ReferencedEnvelope referencedEnvelope = null;
    BufferedImage bufferedImage = null;
    // exampleGridCoverageFactory start
    GridCoverageFactory factory = new GridCoverageFactory();
    GridCoverage2D coverage = factory.create("GridCoverage", bufferedImage, referencedEnvelope);
    // exampleGridCoverageFactory end
}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:11,代码来源:CoverageExamples.java

示例15: convert

import org.geotools.coverage.grid.GridCoverageFactory; //导入依赖的package包/类
@Override
public GridCoverage2D convert(
		final String coverageName,
		final GridCoverage2D originalBandData,
		final SimpleFeature bandMetadata ) {
	final Object attrValue = bandMetadata.getAttribute(BandFeatureIterator.BAND_ATTRIBUTE_NAME);
	if ("BQA".equalsIgnoreCase(attrValue.toString())) {
		final MultiPixelPackedSampleModel newSampleModel = new MultiPixelPackedSampleModel(
				DataBuffer.TYPE_BYTE,
				originalBandData.getRenderedImage().getWidth(),
				originalBandData.getRenderedImage().getHeight(),
				2);
		final WritableRaster nextRaster = Raster.createWritableRaster(
				newSampleModel,
				null);
		final RenderedImage image = originalBandData.getRenderedImage();
		final Raster data = image.getData();
		for (int x = 0; x < data.getWidth(); x++) {
			for (int y = 0; y < data.getHeight(); y++) {
				final int sample = getIceSample(
						x,
						y,
						data);
				nextRaster.setSample(
						x,
						y,
						0,
						sample);
			}
		}
		final GridCoverage2D nextCov = new GridCoverageFactory().create(
				coverageName,
				nextRaster,
				originalBandData.getEnvelope());
		return nextCov;
	}
	return originalBandData;
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:39,代码来源:QABandToIceMaskConverter.java


注:本文中的org.geotools.coverage.grid.GridCoverageFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。