• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java CoverageProcessor类的典型用法和代码示例

java 2次浏览

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

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

示例1: cropEnvelope

点赞 2

import org.geotools.coverage.processing.CoverageProcessor; //导入依赖的package包/类
public FT_Coverage cropEnvelope(Envelope env) {
  GridCoverage2D coverage = this.coverage();
  final CoverageProcessor processor = new CoverageProcessor();
  final ParameterValueGroup param = processor.getOperation("CoverageCrop")
      .getParameters();

  final GeneralEnvelope cropEnv = new GeneralEnvelope(env);
  param.parameter("Source").setValue(coverage);
  param.parameter("Envelope").setValue(cropEnv);
  GridCoverage2D cropped = (GridCoverage2D) processor.doOperation(param);
  return new FT_Coverage(cropped);

}
 

开发者ID:IGNF,
项目名称:geoxygene,
代码行数:14,
代码来源:FT_Coverage.java

示例2: crop

点赞 2

import org.geotools.coverage.processing.CoverageProcessor; //导入依赖的package包/类
public FT_Coverage crop(IGeometry geometry) {

    GridCoverage2D coverage = this.coverage();
    Geometry geom = null;
    try {
      geom = AdapterFactory.toGeometry(new GeometryFactory(), geometry);
    } catch (Exception e) {
      e.printStackTrace();
    }

    final CoverageProcessor processor = new CoverageProcessor();
    final ParameterValueGroup param = processor.getOperation("CoverageCrop")
        .getParameters();
    param.parameter("Source").setValue(coverage);
    param.parameter("ROI").setValue(geom);
    GridCoverage2D cropped = (GridCoverage2D) processor.doOperation(param);

    // FIXME PB de thread asynchrone : le fond est rendu transparent avant que
    // l'image ne soit croppée.
    // FIXME On parcourt l'image pour rendre transparent la partie coupée
    // Ce serait mieux de prévoir que l'image soit transparente à la base ...
    BufferedImage img = ImageUtil.toBufferedImage(cropped.getRenderedImage());

    for (int i = 0; i < img.getWidth(); i++) {
      for (int j = 0; j < img.getHeight(); j++) {
        Color c = new Color(img.getRGB(i, j));
        if (c == Color.BLACK) {
          Color color = new Color(0, 0, 0, 0);
          img.setRGB(i, j, color.getRGB());
        }
      }
    }
    GridCoverage2D cropped_transp = ImageUtil.bufferedImageToGridCoverage2D(img,
        cropped.getEnvelope());
    return new FT_Coverage(cropped_transp);

  }
 

开发者ID:IGNF,
项目名称:geoxygene,
代码行数:38,
代码来源:FT_Coverage.java

示例3: mergePoly

点赞 2

import org.geotools.coverage.processing.CoverageProcessor; //导入依赖的package包/类
private void mergePoly(
		final GridCoverage originalCoverage,
		final Polygon poly,
		final Resolution resolution ) {
	final CoverageProcessor processor = CoverageProcessor.getInstance();
	final AbstractOperation op = (AbstractOperation) processor.getOperation("Histogram");
	final ParameterValueGroup params = op.getParameters();
	params.parameter(
			"Source").setValue(
			originalCoverage);
	params.parameter(
			BaseStatisticsOperationJAI.ROI.getName().getCode()).setValue(
			poly);
	params.parameter(
			"lowValue").setValue(
			histogramConfig.getLowValues());
	params.parameter(
			"highValue").setValue(
			histogramConfig.getHighValues());
	params.parameter(
			"numBins").setValue(
			histogramConfig.getNumBins());
	try {

		final GridCoverage2D coverage = (GridCoverage2D) op.doOperation(
				params,
				null);
		final javax.media.jai.Histogram histogram = (javax.media.jai.Histogram) coverage
				.getProperty(Histogram.GT_SYNTHETIC_PROPERTY_HISTOGRAM);

		javax.media.jai.Histogram mergedHistogram;
		final javax.media.jai.Histogram resolutionHistogram = histograms.get(resolution);
		if (resolutionHistogram != null) {
			mergedHistogram = mergeHistograms(
					resolutionHistogram,
					histogram);
		}
		else {
			mergedHistogram = histogram;
		}
		synchronized (this) {
			histograms.put(
					resolution,
					mergedHistogram);
		}
	}
	catch (final Exception e) {
		// this is simply 'info' because there is a known issue in the
		// histogram op when the ROI is so small that the resulting cropped
		// pixel size is 0
		LOGGER
				.info(
						"This is often a non-issue relating to applying an ROI calculation that results in 0 pixels (the error is in calculating stats).",
						e);
	}

}
 

开发者ID:locationtech,
项目名称:geowave,
代码行数:58,
代码来源:HistogramStatistics.java

示例4: clipImageToFeatureSource

点赞 2

import org.geotools.coverage.processing.CoverageProcessor; //导入依赖的package包/类
private Coverage clipImageToFeatureSource(RenderedImage image, ReferencedEnvelope bounds,
		FeatureSource<SimpleFeatureType, SimpleFeature> featureSource) throws IOException, FactoryException,
		MismatchedDimensionException, TransformException {
	FeatureCollection<SimpleFeatureType, SimpleFeature> collection = featureSource.getFeatures();

	CoordinateReferenceSystem crsFeatures = featureSource.getSchema().getCoordinateReferenceSystem();
	CoordinateReferenceSystem crsMap = bounds.getCoordinateReferenceSystem();
	boolean needsReproject = !CRS.equalsIgnoreMetadata(crsFeatures, crsMap);
	MathTransform transform = CRS.findMathTransform(crsFeatures, crsMap, true);

	FeatureIterator<SimpleFeature> iterator = collection.features();
	List<Geometry> all = new ArrayList<Geometry>();
	try {
		while (iterator.hasNext()) {
			SimpleFeature feature = iterator.next();
			Geometry geometry = (Geometry) feature.getDefaultGeometry();
			if (geometry == null)
				continue;
			if (!geometry.isSimple())
				continue;
			if (needsReproject) {
				geometry = JTS.transform(geometry, transform);
				System.out.println("Reprojected a geometry.  Result is " + geometry.toString());
			}
			Geometry intersection = geometry.intersection(JTS.toGeometry(bounds));
			if (intersection.isEmpty()) {
				continue;
			}
			// String name = (String) feature.getAttribute("NAME");
			// if (name == null)
			// name = (String) feature.getAttribute("CNTRY_NAME");
			if (intersection instanceof MultiPolygon) {
				MultiPolygon mp = (MultiPolygon) intersection;
				for (int i = 0; i < mp.getNumGeometries(); i++) {
					com.vividsolutions.jts.geom.Polygon g = (com.vividsolutions.jts.geom.Polygon) mp.getGeometryN(i);
					Geometry gIntersection = IntersectUtils.intersection(g, JTS.toGeometry(bounds));
					if (gIntersection.isEmpty()) {
						continue;
					}
					all.add(g);
				}
			} else if (intersection instanceof Polygon)
				all.add(intersection);
			else
				continue;
		}
	} finally {
		if (iterator != null) {
			iterator.close();
		}
	}
	GridCoverageFactory gridCoverageFactory = new GridCoverageFactory();
	Coverage coverage = gridCoverageFactory.create("Raster", image, bounds);
	Coverage clippedCoverage = null;
	if (all.size() > 0) {
		CoverageProcessor processor = new CoverageProcessor();
		ParameterValueGroup params = processor.getOperation("CoverageCrop").getParameters();
		params.parameter("Source").setValue(coverage);
		GeometryFactory factory = JTSFactoryFinder.getGeometryFactory(null);
		Geometry[] a = all.toArray(new Geometry[0]);
		GeometryCollection c = new GeometryCollection(a, factory);
		// params.parameter("ENVELOPE").setValue(bounds);
		params.parameter("ROI").setValue(c);
		params.parameter("ForceMosaic").setValue(true);
		clippedCoverage = processor.doOperation(params);
	}
	if (all.size() == 0) {
		logger.info("Crop by shapefile requested but no simple features matched extent!");
	}
	return clippedCoverage;
}
 

开发者ID:lizardtechblog,
项目名称:ExpressZip,
代码行数:72,
代码来源:Job.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)