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


Java AbstractGridCoverage2DReader类代码示例

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


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

示例1: createRGBStyle

import org.geotools.coverage.grid.io.AbstractGridCoverage2DReader; //导入依赖的package包/类
/**
 * Creates the rgb style.
 *
 * @param reader the reader
 * @param raster the raster
 * @return the style
 */
private Style createRGBStyle(AbstractGridCoverage2DReader reader, WritableRaster raster) {
    RasterSymbolizer sym = sf.getDefaultRasterSymbolizer();

    GridCoverage2D cov = null;
    try {
        cov = reader.read(null);
    } catch (IOException giveUp) {
        throw new RuntimeException(giveUp);
    }
    // We need at least three bands to create an RGB style
    int numBands = cov.getNumSampleDimensions();
    if (numBands < 3) {
        createRGBImageSymbol(sym, cov, raster);
    } else {
        createRGBChannelSymbol(sym, cov, numBands);
    }
    return SLD.wrapSymbolizers(sym);
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:26,代码来源:RasterReader.java

示例2: run

import org.geotools.coverage.grid.io.AbstractGridCoverage2DReader; //导入依赖的package包/类
@Override
public void run() {
	final Display display = WorkbenchHelper.getDisplay();
	final Shell shell = new Shell(display);
	final File openFile = JFileImageChooser.showOpenFile(shell);

	if (openFile != null && openFile.exists()) {
		final AbstractGridFormat format = GridFormatFinder.findFormat(openFile);
		final AbstractGridCoverage2DReader tiffReader = format.getReader(openFile);
		final StyleFactoryImpl sf = new StyleFactoryImpl();
		final RasterSymbolizer symbolizer = sf.getDefaultRasterSymbolizer();
		final Style defaultStyle = SLD.wrapSymbolizers(symbolizer);

		final MapContent mapContent = mapPane.getMapContent();
		final Layer layer = new GridReaderLayer(tiffReader, defaultStyle);
		layer.setTitle(openFile.getName());
		mapContent.addLayer(layer);
		mapPane.redraw();
	}
}
 
开发者ID:gama-platform,项目名称:gama,代码行数:21,代码来源:OpenGeotiffAction.java

示例3: readGridcoverageImageForTile

import org.geotools.coverage.grid.io.AbstractGridCoverage2DReader; //导入依赖的package包/类
/**
 * Read the image of a tile from a generic geotools coverage reader.
 * 
 * @param reader the reader, expected to be in CRS 3857.
 * @param x the tile x.
 * @param y the tile y.
 * @param zoom the zoomlevel.
 * @return the image.
 * @throws IOException 
 */
public static BufferedImage readGridcoverageImageForTile(AbstractGridCoverage2DReader reader, int x, int y,
    int zoom, CoordinateReferenceSystem resampleCrs) throws IOException {
    double north = tile2lat(y, zoom);
    double south = tile2lat(y + 1, zoom);
    double west = tile2lon(x, zoom);
    double east = tile2lon(x + 1, zoom);

    Coordinate ll = new Coordinate(west, south);
    Coordinate ur = new Coordinate(east, north);

    try {
        CoordinateReferenceSystem sourceCRS = DefaultGeographicCRS.WGS84;

        MathTransform transform = CRS.findMathTransform(sourceCRS, resampleCrs);
        ll = JTS.transform(ll, null, transform);
        ur = JTS.transform(ur, null, transform);
    } catch (Exception e) {
        e.printStackTrace();
    }

    BufferedImage image =
        ImageUtilities.imageFromReader(reader, TILESIZE, TILESIZE, ll.x, ur.x, ll.y, ur.y, resampleCrs);
    return image;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:35,代码来源:MBTilesHelper.java

示例4: getRenderer

import org.geotools.coverage.grid.io.AbstractGridCoverage2DReader; //导入依赖的package包/类
private static GTRenderer getRenderer( File rasterFile ) {

        AbstractGridFormat format = GridFormatFinder.findFormat(rasterFile);
        AbstractGridCoverage2DReader coverageReader = format.getReader(rasterFile);

        MapContent mapContent = new MapContent();
        try {

            Style rasterStyle = SldUtilities.getStyleFromFile(rasterFile);
            if (rasterStyle == null) {
                RasterSymbolizer sym = SldUtilities.sf.getDefaultRasterSymbolizer();
                rasterStyle = SLD.wrapSymbolizers(sym);
            }

            GridReaderLayer layer = new GridReaderLayer(coverageReader, rasterStyle);
            mapContent.addLayer(layer);
            mapContent.getViewport().setCoordinateReferenceSystem(CrsUtilities.WGS84);
        } catch (Exception e) {
            e.printStackTrace();
        }
        GTRenderer renderer = new StreamingRenderer();
        renderer.setMapContent(mapContent);
        return renderer;
    }
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:25,代码来源:GridCoverageNwwLayer.java

示例5: getReader

import org.geotools.coverage.grid.io.AbstractGridCoverage2DReader; //导入依赖的package包/类
@Override
public AbstractGridCoverage2DReader getReader(
		final Object source,
		final Hints hints ) {
	try {
		return new GeoWaveRasterReader(
				source,
				hints);
	}
	catch (final Exception e) {
		LOGGER.warn(
				"Cannot create geowave raster reader",
				e);

		return null;
	}
}
 
开发者ID:locationtech,项目名称:geowave,代码行数:18,代码来源:GeoWaveGTRasterFormat.java

示例6: getGridCoverageReader

import org.geotools.coverage.grid.io.AbstractGridCoverage2DReader; //导入依赖的package包/类
/**
 * Gets the grid coverage reader.
 *
 * @return the grid coverage reader
 */
@Override
public AbstractGridCoverage2DReader getGridCoverageReader() {
    AbstractGridCoverage2DReader gridCoverage = null;

    if (dataSourceInfo != null) {
        gridCoverage = dataSourceInfo.getGridCoverageReader();
    }
    return gridCoverage;
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:15,代码来源:DataSourceImpl.java

示例7: getReader

import org.geotools.coverage.grid.io.AbstractGridCoverage2DReader; //导入依赖的package包/类
@Override
public AbstractGridCoverage2DReader getReader(Object source, Hints hints)
{File configfile = null;
  if (source instanceof URI)
  {
    configfile = new File((URI) source);
  }
  else if (source instanceof String)
  {
    configfile = new File(source.toString());
  }
  else if (source instanceof File)
  {
    configfile = (File)source;
  }

  if (configfile != null)
  {
    try
    {
      return new MrGeoReader(config);
    }
    catch (Exception ignored)
    {
      ignored.printStackTrace();
    }
  }

  log.severe("Can't create MrGeoReader.  (config: " + (configfile == null ? "null" : configfile.toURI().toString()) + ")");
  return null;
}
 
开发者ID:ngageoint,项目名称:mrgeo-geoserver-plugin,代码行数:32,代码来源:MrGeoFormat.java

示例8: main

import org.geotools.coverage.grid.io.AbstractGridCoverage2DReader; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
    String ctp = "/home/hydrologis/data/CTP/trentino_ctp/ctp.shp";
    File file = new File(ctp);
    AbstractGridFormat format = GridFormatFinder.findFormat(file);
    AbstractGridCoverage2DReader reader = format.getReader(file);
    BufferedImage image = MBTilesHelper.readGridcoverageImageForTile(reader, 1, 1, 19, null);

}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:9,代码来源:MBTilesHelper.java

示例9: SaveMapAsImage

import org.geotools.coverage.grid.io.AbstractGridCoverage2DReader; //导入依赖的package包/类
public SaveMapAsImage(File file, File raster) throws IOException {

		FileDataStore store = FileDataStoreFinder.getDataStore(file);
		SimpleFeatureSource featureSource = store.getFeatureSource();

		// Create a map content and add our shapefile to it
		mapContent = new MapContent();
		mapContent.setTitle("GeoTools Mapping");
		AbstractGridFormat format = GridFormatFinder.findFormat(raster);
		AbstractGridCoverage2DReader reader = format.getReader(raster);
		GridCoverage2D cov;
		try {
			cov = reader.read(null);
		} catch (IOException giveUp) {
			throw new RuntimeException(giveUp);
		}
		Style rasterStyle = createRGBStyle(cov);
		Layer rasterLayer = new GridReaderLayer(reader, rasterStyle);
		mapContent.addLayer(rasterLayer);

		Style style = SLD.createSimpleStyle(featureSource.getSchema());
		Layer layer = new FeatureLayer(featureSource, style);
		mapContent.addLayer(layer);
		mapContent.getViewport().setCoordinateReferenceSystem(
				DefaultGeographicCRS.WGS84);
		frame = new JMapFrame(mapContent);
		frame.enableStatusBar(true);
		frame.enableToolBar(true);
		JToolBar toolBar = frame.getToolBar();
		toolBar.addSeparator();
		SaveAction save = new SaveAction("Save");
		toolBar.add(save);
		frame.initComponents();
		frame.setSize(1000, 500);
		frame.setVisible(true);
	}
 
开发者ID:ianturton,项目名称:geotools-cookbook,代码行数:37,代码来源:SaveMapAsImage.java

示例10: createRasterLayer

import org.geotools.coverage.grid.io.AbstractGridCoverage2DReader; //导入依赖的package包/类
private Layer createRasterLayer(File file, DataSet target_dataset)
    throws IOException {
  // declaration & initialization
  Layer layer = null;
  AbstractGridCoverage2DReader reader;

  // Give a name to the population
  String populationName = popNameFromFile(file.getPath());

  // Find the file format
  AbstractGridFormat format = GridFormatFinder.findFormat(file);

  // Find out if we can read the file ...
  // Unkown Format is not a typo from me, it is a typo from Geotools ...
  if (format.getName() != "Unkown Format") {
    reader = format.getReader(file);
  } else {
    System.err.println("Unknown file format for : " + file.getName());
    return null;
  }

  // ... and do it
  GridCoverage2D coverage = (GridCoverage2D) reader.read(null);

  // create a population
  Population<FT_Coverage> population = new Population<FT_Coverage>(
      populationName);
  org.opengis.geometry.Envelope envelope = coverage.getEnvelope();

  // put the envelope of the image in the population
  population.setEnvelope(
      new GM_Envelope(envelope.getLowerCorner().getCoordinate()[0],
          envelope.getUpperCorner().getCoordinate()[0],
          envelope.getLowerCorner().getCoordinate()[1],
          envelope.getUpperCorner().getCoordinate()[1]));

  // add the data to the population
  population.add(new FT_Coverage(coverage));

  target_dataset.addPopulation(population);

  // create a layer
  layer = this.createLayer(populationName);

  return layer;
}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:47,代码来源:LayerFactory.java

示例11: getGridCoverageReader

import org.geotools.coverage.grid.io.AbstractGridCoverage2DReader; //导入依赖的package包/类
@Override
public AbstractGridCoverage2DReader getGridCoverageReader() {
    return null;
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:5,代码来源:DataSourceFactoryTest.java

示例12: generateOverviews

import org.geotools.coverage.grid.io.AbstractGridCoverage2DReader; //导入依赖的package包/类
/**
 * @param retValue
 * @return the number of steps processed, or 0 if none was done, or -1 on error.
 * @throws DataSourceException
 */
public static int generateOverviews(AbstractGridCoverage2DReader abstractGridCoverage2DReader)
        throws DataSourceException {
    final File geotiffFile = (File) abstractGridCoverage2DReader.getSource();
    // ////
    // Adding Overviews
    // ////

    int tileH = 512;
    int tileW = 512;

    /** computing the number of steps **/
    GridEnvelope gridRange = abstractGridCoverage2DReader.getOriginalGridRange();

    int height = gridRange.getSpan(1);
    int width = gridRange.getSpan(0);

    int ratioH = (int) Math.ceil((1.0 * height) / tileH);
    int ratioW = (int) Math.ceil((1.0 * width) / tileW);

    int nStepsH = 0;
    int nStepsW = 0;

    if (ratioH >= 2) {
        nStepsH = (int) Math.floor(Math.log(ratioH) / Math.log(2));
    }

    if (ratioW >= 2) {
        nStepsW = (int) Math.floor(Math.log(ratioW) / Math.log(2));
    }

    int numSteps = Math.min(nStepsH, nStepsW);
    int downSampleSteps = 2;

    if (numSteps > 0) {
        final OverviewsEmbedder oe = new OverviewsEmbedder();
        oe.setDownsampleStep(downSampleSteps);
        oe.setNumSteps(numSteps);
        oe.setScaleAlgorithm(OverviewsEmbedder.SubsampleAlgorithm.Nearest.toString());
        oe.setTileCache(JAI.getDefaultInstance().getTileCache());
        // oe.setTileHeight(tileH);
        // oe.setTileWidth(tileW);
        oe.setSourcePath(geotiffFile.getAbsolutePath());

        EmbedderListener listener = new EmbedderListener(geotiffFile.getAbsolutePath());
        // add logger/listener
        oe.addProcessingEventListener(listener);

        // run
        oe.run(); // should block until terminated
        return listener.isSuccess() ? numSteps : -1;
    } else
        return 0;
}
 
开发者ID:geosolutions-it,项目名称:soil_sealing,代码行数:59,代码来源:CoverageUtilities.java

示例13: getGridCoverageReader

import org.geotools.coverage.grid.io.AbstractGridCoverage2DReader; //导入依赖的package包/类
/**
 * Gets the grid coverage reader.
 *
 * @return the gridCoverage reader
 */
public AbstractGridCoverage2DReader getGridCoverageReader() {
    return gridCoverageReader;
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:9,代码来源:DataSourceInfo.java

示例14: setGridCoverageReader

import org.geotools.coverage.grid.io.AbstractGridCoverage2DReader; //导入依赖的package包/类
/**
 * Sets the grid coverage reader.
 *
 * @param gridCoverage the gridCoverage to set
 */
public void setGridCoverageReader(AbstractGridCoverage2DReader gridCoverage) {
    this.gridCoverageReader = gridCoverage;
    geometryType = GeometryTypeEnum.RASTER;
}
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:10,代码来源:DataSourceInfo.java

示例15: getGridCoverageReader

import org.geotools.coverage.grid.io.AbstractGridCoverage2DReader; //导入依赖的package包/类
/**
 * Gets the grid coverage reader.
 *
 * @return the grid coverage reader
 */
AbstractGridCoverage2DReader getGridCoverageReader();
 
开发者ID:robward-scisys,项目名称:sldeditor,代码行数:7,代码来源:DataSourceInterface.java


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