• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java AffineTransform2D类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: initBandGeoCoding

import org.geotools.referencing.operation.transform.AffineTransform2D; //导入依赖的package包/类
private void initBandGeoCoding(ImageMetadata imageMetadata, Band band, int sceneWidth, int sceneHeight) {
    int bandWidth = imageMetadata.getRasterWidth();
    int bandHeight = imageMetadata.getRasterHeight();
    GeoCoding geoCoding = null;
    ImageMetadata.InsertionPoint insertPoint = imageMetadata.getInsertPoint();
    String crsCode = imageMetadata.getCRSCode();
    try {
        CoordinateReferenceSystem crs = CRS.decode(crsCode);
        if (imageMetadata.hasInsertPoint()) {
                geoCoding = new CrsGeoCoding(crs,
                        bandWidth, bandHeight,
                        insertPoint.x, insertPoint.y,
                        insertPoint.stepX, insertPoint.stepY, 0.0, 0.0);
        } else {
            if (sceneWidth != bandWidth) {
                AffineTransform2D transform2D = new AffineTransform2D((float) sceneWidth / bandWidth, 0.0, 0.0, (float) sceneHeight / bandHeight, 0.0, 0.0);
                band.setImageToModelTransform(transform2D);
            }
        }
    } catch (Exception e) {
        logger.warning(e.getMessage());
    }
    band.setGeoCoding(geoCoding);
}
 
开发者ID:senbox-org,项目名称:s2tbx,代码行数:25,代码来源:Spot6ProductReader.java


示例2: computeRect

import org.geotools.referencing.operation.transform.AffineTransform2D; //导入依赖的package包/类
@Override
        protected void computeRect(PlanarImage[] sourceImages, WritableRaster tile, Rectangle destRect) {
            final BufferedImage image = new BufferedImage(colorModel,
                    RasterFactory.createWritableRaster(tile.getSampleModel(),
                            tile.getDataBuffer(),
                            new Point(0, 0)), false, null);
            final Graphics2D graphics2D = image.createGraphics();
            graphics2D.translate(-(tile.getMinX() + 0.5), -(tile.getMinY() + 0.5));
            graphics2D.setColor(Color.WHITE);

            FeatureIterator<SimpleFeature> featureIterator = featureCollection.features();
            try {
                AffineTransform transform = AffineTransform.getScaleInstance(1.0 / getScale(), 1.0 / getScale());
//                transform.concatenate(m2iTransform);
                AffineTransform2D transform2D = new AffineTransform2D(transform);

                while (featureIterator.hasNext()) {
                    SimpleFeature feature = featureIterator.next();
                    Object value = feature.getDefaultGeometry();
                    if (value instanceof Geometry) {
                        try {
                            renderGeometry((Geometry) value, graphics2D, transform2D);
                        } catch (Exception ignored) {
                            // ignore
                        }
                    }
                }
            } finally {
                featureIterator.close();
            }

            graphics2D.dispose();

            final byte[] data = ((DataBufferByte) tile.getDataBuffer()).getData();
            for (int i = 0; i < data.length; i++) {
                data[i] = (data[i] != 0) ? TRUE : FALSE;
            }
        }
 
开发者ID:senbox-org,项目名称:s2tbx,代码行数:39,代码来源:PathRasterizer.java


示例3: scaleToUnitaryArea

import org.geotools.referencing.operation.transform.AffineTransform2D; //导入依赖的package包/类
/**
 * Scales a {@link Polygon} to have an unitary area.
 * 
 * @param polygon the geometry to scale.
 * @return a copy of the scaled geometry.
 * @throws Exception 
 */
public static Geometry scaleToUnitaryArea( Geometry polygon ) throws Exception {
    double area = polygon.getArea();
    double scale = sqrt(1.0 / area);
    AffineTransform scaleAT = new AffineTransform();
    scaleAT.scale(scale, scale);
    AffineTransform2D scaleTransform = new AffineTransform2D(scaleAT);
    polygon = JTS.transform(polygon, scaleTransform);
    return polygon;
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:17,代码来源:GeometryUtilities.java


示例4: prepareROI

import org.geotools.referencing.operation.transform.AffineTransform2D; //导入依赖的package包/类
/**
 * Utility method for transforming a geometry ROI into the raster space, using the provided affine transformation.
 * 
 * @param roi a {@link Geometry} in model space.
 * @param mt2d an {@link AffineTransform} that maps from raster to model space. This is already referred to the pixel corner.
 * @return a {@link ROI} suitable for using with JAI.
 * @throws ProcessException in case there are problems with ivnerting the provided {@link AffineTransform}. Very unlikely to happen.
 */
public static ROI prepareROI( Geometry roi, AffineTransform mt2d ) throws Exception {
    // transform the geometry to raster space so that we can use it as a ROI source
    Geometry rasterSpaceGeometry = JTS.transform(roi, new AffineTransform2D(mt2d.createInverse()));

    // simplify the geometry so that it's as precise as the coverage, excess coordinates
    // just make it slower to determine the point in polygon relationship
    Geometry simplifiedGeometry = DouglasPeuckerSimplifier.simplify(rasterSpaceGeometry, 1);

    // build a shape using a fast point in polygon wrapper
    return new ROIShape(new FastLiteShape(simplifiedGeometry));
}
 
开发者ID:TheHortonMachine,项目名称:hortonmachine,代码行数:20,代码来源:CoverageUtilities.java


示例5: testGetPatchCoordinates

import org.geotools.referencing.operation.transform.AffineTransform2D; //导入依赖的package包/类
@Test
public void testGetPatchCoordinates() throws Exception {
    final Rectangle r = new Rectangle(0, 0, 200, 200);
    final MathTransform t = new AffineTransform2D(new AffineTransform());

    final Point patchCoordinates = patchGrid.getPatchCoordinates(r, t);
    assertEquals(90, patchCoordinates.x);
    assertEquals(45, patchCoordinates.y);
}
 
开发者ID:bcdev,项目名称:esa-pfa,代码行数:10,代码来源:PatchGridTest.java


示例6: getSampleShape

import org.geotools.referencing.operation.transform.AffineTransform2D; //导入依赖的package包/类
private LiteShape2 getSampleShape(Symbolizer symbolizer, int width, int height) {
	MetaBufferEstimator estimator = new MetaBufferEstimator();
	estimator.visit(symbolizer);
	// add an extra pixel to the margin (odd line widths were not always shown)
	int margin = estimator.getBuffer() + 1;
	// we define a shape in WKT of size 1 x 1 and transform it to a rectangle of (width-margin) x (height-margin),
	// to make sure we capture thick strokes
	MathTransform transform = new AffineTransform2D(width - margin, 0, 0, height - margin, 0.5 * margin,
			0.5 * margin);
	try {
		WKTReader wktReader = new WKTReader();
		if (symbolizer instanceof LineSymbolizer) {
			return new LiteShape2(wktReader.read("LINESTRING (0 0, 0.66 0.33, 0.33 0.66, 1 1)"), transform, null,
					false);
		} else if (symbolizer instanceof PolygonSymbolizer) {
			return new LiteShape2(wktReader.read("POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))"), transform, null, false);
		} else if (symbolizer instanceof PointSymbolizer) {
			return new LiteShape2(wktReader.read("POINT (0.5 0.5)"), transform, null, false);
		} else {
			return null;
		}
	} catch (Exception e) { // NOSONAR
		// should not happen
		log.warn("Could not create sample shapes", e);
		return null;
	}
}
 
开发者ID:geomajas,项目名称:geomajas-project-server,代码行数:28,代码来源:LegendGraphicServiceImpl.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PlatformBitmapFactory类代码示例发布时间:2022-05-23
下一篇:
Java KeyHelper类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap