本文整理汇总了Java中org.opengis.metadata.spatial.PixelOrientation类的典型用法代码示例。如果您正苦于以下问题:Java PixelOrientation类的具体用法?Java PixelOrientation怎么用?Java PixelOrientation使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PixelOrientation类属于org.opengis.metadata.spatial包,在下文中一共展示了PixelOrientation类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: doVectorize
import org.opengis.metadata.spatial.PixelOrientation; //导入依赖的package包/类
/**
* Helper function to run the Vectorize operation with given parameters and
* retrieve the vectors.
*
* @param src the source {@link GridCoverage2D}.
* @param args a {@code Map} of parameter names and values or <code>null</code>.
*
* @return the generated vectors as JTS Polygons
*/
@SuppressWarnings("unchecked")
public static Collection<Polygon> doVectorize( GridCoverage2D src, Map<String, Object> args ) {
if (args == null) {
args = new HashMap<String, Object>();
}
ParameterBlockJAI pb = new ParameterBlockJAI("Vectorize");
pb.setSource("source0", src.getRenderedImage());
// Set any parameters that were passed in
for( Entry<String, Object> e : args.entrySet() ) {
pb.setParameter(e.getKey(), e.getValue());
}
// Get the desintation image: this is the unmodified source image data
// plus a property for the generated vectors
RenderedOp dest = JAI.create("Vectorize", pb);
// Get the vectors
Collection<Polygon> polygons = (Collection<Polygon>) dest.getProperty(VectorizeDescriptor.VECTOR_PROPERTY_NAME);
RegionMap regionParams = CoverageUtilities.getRegionParamsFromGridCoverage(src);
double xRes = regionParams.getXres();
double yRes = regionParams.getYres();
final AffineTransform mt2D = (AffineTransform) src.getGridGeometry().getGridToCRS2D(PixelOrientation.CENTER);
final AffineTransformation jtsTransformation = new AffineTransformation(mt2D.getScaleX(), mt2D.getShearX(),
mt2D.getTranslateX() - xRes / 2.0, mt2D.getShearY(), mt2D.getScaleY(), mt2D.getTranslateY() + yRes / 2.0);
for( Polygon polygon : polygons ) {
polygon.apply(jtsTransformation);
}
return polygons;
}
示例2: AreaOpImage
import org.opengis.metadata.spatial.PixelOrientation; //导入依赖的package包/类
public AreaOpImage(RenderedImage source, ImageLayout layout, Map configuration,
ReferencedEnvelope env, double multiplier, Set<Integer> validValues, ROI roi) {
super(source, layoutHelper(source, layout), configuration, true);
this.multi = multiplier;
this.validCheck = validValues != null && !validValues.isEmpty();
this.validValues = validValues;
this.envelope = env;
// Creation of a GridGeometry in order to calculate the gridToWorld transform
GridEnvelope gridRange = new GridEnvelope2D(getBounds());
GridGeometry2D gg = new GridGeometry2D(gridRange, env);
g2w = gg.getGridToCRS2D(PixelOrientation.UPPER_LEFT);
CoordinateReferenceSystem sourceCRS = envelope.getCoordinateReferenceSystem();
try {
CoordinateReferenceSystem targetCRS = CRS.parseWKT(TARGET_CRS_WKT);
transform = CRS.findMathTransform(sourceCRS, targetCRS);
} catch (FactoryException e) {
LOGGER.log(Level.SEVERE, e.getMessage(), e);
throw new IllegalArgumentException(e);
}
// Setting of the roi
this.roiUsed = roi;
if (roi != null) {
// Setting a roi flag to true
this.noROI = false;
// check that the ROI contains the source image bounds
final Rectangle sourceBounds = new Rectangle(source.getMinX(), source.getMinY(),
source.getWidth(), source.getHeight());
// Check if the ROI intersects the image bounds
if (!roi.intersects(sourceBounds)) {
throw new IllegalArgumentException(
"The bounds of the ROI must intersect the source image");
}
// massage roi
roiUsed = roi.intersect(new ROIShape(sourceBounds));
} else {
this.noROI = true;
}
}