本文整理汇总了Java中org.opengis.geometry.Envelope类的典型用法代码示例。如果您正苦于以下问题:Java Envelope类的具体用法?Java Envelope怎么用?Java Envelope使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Envelope类属于org.opengis.geometry包,在下文中一共展示了Envelope类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: parse
import org.opengis.geometry.Envelope; //导入依赖的package包/类
@Override
public Object parse(ElementInstance instance, Node node, Object value) throws Exception {
Envelope envelope = (Envelope) super.parse(instance, node, value);
// handle the box CRS
CoordinateReferenceSystem crs = this.crs;
if (node.hasAttribute("srsName")) {
URI srs = (URI) node.getAttributeValue("srsName");
crs = CRS.decode(srs.toString());
}
if(crs != null) {
return ReferencedEnvelope.create(envelope, crs);
} else {
return envelope;
}
}
示例2: getBoundaryProduct
import org.opengis.geometry.Envelope; //导入依赖的package包/类
public Product getBoundaryProduct() throws FactoryException, TransformException {
final CoordinateReferenceSystem mapCRS = getTargetCRS();
if (mapCRS != null) {
final ReferencedEnvelope envelope = getTargetEnvelope();
final Envelope mapEnvelope = envelope.transform(mapCRS, true);
final double pixelSizeX = (Double) getPropertyValue(PROPERTY_PIXEL_SIZE_X);
final double pixelSizeY = (Double) getPropertyValue(PROPERTY_PIXEL_SIZE_Y);
final int w = MathUtils.floorInt(mapEnvelope.getSpan(0) / pixelSizeX);
final int h = MathUtils.floorInt(mapEnvelope.getSpan(1) / pixelSizeY);
final Product product = new Product("mosaic", "MosaicBounds", w, h);
final GeoCoding geoCoding = new CrsGeoCoding(mapCRS,
w, h,
mapEnvelope.getMinimum(0),
mapEnvelope.getMaximum(1),
pixelSizeX, pixelSizeY);
product.setSceneGeoCoding(geoCoding);
return product;
}
return null;
}
示例3: setCrs
import org.opengis.geometry.Envelope; //导入依赖的package包/类
public void setCrs(final CoordinateReferenceSystem crs) {
try {
// System.out.println(content.layers().size());
final ReferencedEnvelope rEnv = getDisplayArea();
// System.out.println(rEnv);
final CoordinateReferenceSystem sourceCRS = rEnv.getCoordinateReferenceSystem();
final CoordinateReferenceSystem targetCRS = crs;
final MathTransform transform = CRS.findMathTransform(sourceCRS, targetCRS);
final com.vividsolutions.jts.geom.Envelope newJtsEnv = JTS.transform(rEnv, transform);
final ReferencedEnvelope newEnvelope = new ReferencedEnvelope(newJtsEnv, targetCRS);
content.getViewport().setBounds(newEnvelope);
fullExtent = null;
doSetDisplayArea(newEnvelope);
// ReferencedEnvelope displayArea =
getDisplayArea();
// System.out.println(displayArea);
} catch (final Exception e) {
e.printStackTrace();
}
}
示例4: getRegionArrayFromGridCoverage
import org.opengis.geometry.Envelope; //导入依赖的package包/类
/**
* Get the array of region parameters covered by the {@link GridCoverage2D coverage}.
*
* @param gridCoverage the coverage.
* @return the array of region parameters as [n, s, w, e, xres, yres, cols, rows]
*/
public static double[] getRegionArrayFromGridCoverage( GridCoverage2D gridCoverage ) {
Envelope envelope = gridCoverage.getEnvelope();
DirectPosition lowerCorner = envelope.getLowerCorner();
double[] westSouth = lowerCorner.getCoordinate();
DirectPosition upperCorner = envelope.getUpperCorner();
double[] eastNorth = upperCorner.getCoordinate();
GridGeometry2D gridGeometry = gridCoverage.getGridGeometry();
GridEnvelope2D gridRange = gridGeometry.getGridRange2D();
int height = gridRange.height;
int width = gridRange.width;
AffineTransform gridToCRS = (AffineTransform) gridGeometry.getGridToCRS();
double xRes = XAffineTransform.getScaleX0(gridToCRS);
double yRes = XAffineTransform.getScaleY0(gridToCRS);
double[] params = new double[]{eastNorth[1], westSouth[1], westSouth[0], eastNorth[0], xRes, yRes, width, height};
return params;
}
示例5: getReferenceEnvelope
import org.opengis.geometry.Envelope; //导入依赖的package包/类
public static ReferencedEnvelope getReferenceEnvelope(
final GridCoverage gridCoverage,
final CoordinateReferenceSystem targetCrs ) {
final CoordinateReferenceSystem sourceCrs = gridCoverage.getCoordinateReferenceSystem();
final Envelope sampleEnvelope = gridCoverage.getEnvelope();
final ReferencedEnvelope sampleReferencedEnvelope = new ReferencedEnvelope(
new com.vividsolutions.jts.geom.Envelope(
sampleEnvelope.getMinimum(0),
sampleEnvelope.getMaximum(0),
sampleEnvelope.getMinimum(1),
sampleEnvelope.getMaximum(1)),
gridCoverage.getCoordinateReferenceSystem());
ReferencedEnvelope projectedReferenceEnvelope = sampleReferencedEnvelope;
if ((targetCrs != null) && !targetCrs.equals(sourceCrs)) {
try {
projectedReferenceEnvelope = sampleReferencedEnvelope.transform(
targetCrs,
true);
}
catch (TransformException | FactoryException e) {
LOGGER.warn(
"Unable to transform envelope of grid coverage to " + targetCrs.getName(),
e);
}
}
return projectedReferenceEnvelope;
}
示例6: createWritableSerializer
import org.opengis.geometry.Envelope; //导入依赖的package包/类
@Override
public HadoopWritableSerializer<GridCoverage, GridCoverageWritable> createWritableSerializer() {
return new HadoopWritableSerializer<GridCoverage, GridCoverageWritable>() {
@Override
public GridCoverageWritable toWritable(
final GridCoverage entry ) {
final Envelope env = entry.getEnvelope();
final DataBuffer dataBuffer = entry.getRenderedImage().copyData(
new InternalWritableRaster(
sampleModel.createCompatibleSampleModel(
tileSize,
tileSize),
new Point())).getDataBuffer();
Persistable metadata = null;
if (entry instanceof GridCoverage2D) {
final Object metadataObj = ((GridCoverage2D) entry).getProperty(TILE_METADATA_PROPERTY_KEY);
if ((metadataObj != null) && (metadataObj instanceof Persistable)) {
metadata = (Persistable) metadataObj;
}
}
return new GridCoverageWritable(
new RasterTile(
dataBuffer,
metadata),
env.getMinimum(0),
env.getMaximum(0),
env.getMinimum(1),
env.getMaximum(1));
}
@Override
public GridCoverage fromWritable(
final GridCoverageWritable writable ) {
final ReferencedEnvelope mapExtent = new ReferencedEnvelope(
writable.getMinX(),
writable.getMaxX(),
writable.getMinY(),
writable.getMaxY(),
GeoWaveGTRasterFormat.DEFAULT_CRS);
try {
return prepareCoverage(
writable.getRasterTile(),
tileSize,
mapExtent);
}
catch (final IOException e) {
LOGGER.error(
"Unable to read raster data",
e);
}
return null;
}
};
}
示例7: FitToIndexGridCoverage
import org.opengis.geometry.Envelope; //导入依赖的package包/类
public FitToIndexGridCoverage(
final GridCoverage gridCoverage,
final ByteArrayId insertionId,
final Resolution resolution,
final Envelope originalEnvelope,
final Geometry footprintWorldGeometry,
final Geometry footprintScreenGeometry,
final Map properties ) {
this.gridCoverage = gridCoverage;
this.insertionId = insertionId;
this.resolution = resolution;
this.originalEnvelope = originalEnvelope;
this.footprintWorldGeometry = footprintWorldGeometry;
this.footprintScreenGeometry = footprintScreenGeometry;
this.properties = properties;
}
示例8: createTileLoader
import org.opengis.geometry.Envelope; //导入依赖的package包/类
@Override
protected Callable<GridCoverage2D> createTileLoader(Coordinate coord) {
// Get the tile prefix, eg 'w140n40'
final String tile = getTileName(coord);
final Envelope tileBounds = getTileEnvelope(coord);
// file to fetch from ftp
final String fileBase = tile + ".Bathymetry.srtm";
// Download the data files asynchronously
// Should take about 40s to download dem file
try {
cache.prefetch(fileBase+".dem", new URL(SMTP_PLUS_SERVER+fileBase) );
cache.prefetch(fileBase+".ers", new URL(SMTP_PLUS_SERVER+fileBase+".ers") );
// Create bogus GTopo30 files for the inflexible Reader
createHDR(fileBase+".hdr",tileBounds);
createPRJ(fileBase+".prj");
createSTX(fileBase+".stx");
} catch (MalformedURLException e) {
throw new RuntimeException("[Bug] bad URL for downloading tile "+tile,e);
}
return new GridLoader(tile, fileBase);
}
示例9: FT_Coverage
import org.opengis.geometry.Envelope; //导入依赖的package包/类
public FT_Coverage(GridCoverage2D coverage) {
this.setCoverage(coverage);
Envelope envelope = coverage.getEnvelope();
this.setBox(new GM_Envelope(
new DirectPosition(envelope.getUpperCorner().getCoordinate()),
new DirectPosition(envelope.getLowerCorner().getCoordinate())));
}
示例10: cropEnvelope
import org.opengis.geometry.Envelope; //导入依赖的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);
}
示例11: bufferredImageToGridCovergade2D
import org.opengis.geometry.Envelope; //导入依赖的package包/类
public static GridCoverage2D bufferredImageToGridCovergade2D(
BufferedImage image,
IFeatureCollection<? extends IFeature> templateFeatColl) {
Envelope env = ((FT_Coverage) templateFeatColl.get(0)).coverage()
.getEnvelope();
return bufferedImageToGridCoverage2D(image, env);
}
示例12: setValue
import org.opengis.geometry.Envelope; //导入依赖的package包/类
@Override
public void setValue(Object aValue) {
this.value = null;
this.expression = null;
if (aValue instanceof Envelope) {
this.value = (Envelope) aValue;
} else if ((aValue instanceof AttributeExpressionImpl)
|| (aValue instanceof FunctionExpressionImpl)
|| (aValue instanceof LiteralExpressionImpl)
|| (aValue instanceof MathExpressionImpl)) {
this.expression = (Expression) aValue;
}
}
示例13: calculateBBox
import org.opengis.geometry.Envelope; //导入依赖的package包/类
/**
* Calculates the bounds for 4 different text fields.
* @param x1 tf with x1
* @param x2 tf with x2
* @param y1 tf with y1
* @param y2 tf with y2
* @param crs the CRS of the Bounding Box
* @return the bounding box
*/
public static Envelope2D calculateBBox(TextField x1,
TextField x2,
TextField y1,
TextField y2,
CoordinateReferenceSystem crs) {
if (x1 != null
&& x2 != null
&& y1 != null
&& y2 != null
&& !x1.getText().toString().isEmpty()
&& !x2.toString().isEmpty()
&& !y1.toString().isEmpty()
&& !y2.toString().isEmpty()) {
Double x1Coordinate = Double.parseDouble(
x1.getText().toString());
Double x2Coordinate = Double.parseDouble(
x2.getText().toString());
Double y1Coordinate = Double.parseDouble(
y1.getText().toString());
Double y2Coordinate = Double.parseDouble(
y2.getText().toString());
Envelope env = new ReferencedEnvelope(
x1Coordinate,
x2Coordinate,
y1Coordinate,
y2Coordinate,
crs);
return new Envelope2D(env);
}
return null;
}
示例14: doSetDisplayArea
import org.opengis.geometry.Envelope; //导入依赖的package包/类
/**
* Helper method for {@linkplain #setDisplayArea} which is also called by
* other methods that want to set the display area without provoking
* repainting of the display
*
* @param envelope
* requested display area
*/
private void doSetDisplayArea(final Envelope envelope) {
assert content != null && curPaintArea != null && !curPaintArea.isEmpty();
if (equalsFullExtent(envelope)) {
setTransforms(fullExtent, curPaintArea);
} else {
setTransforms(envelope, curPaintArea);
}
final ReferencedEnvelope adjustedEnvelope = getDisplayArea();
content.getViewport().setBounds(adjustedEnvelope);
final MapPaneEvent ev = new MapPaneEvent(this, MapPaneEvent.Type.DISPLAY_AREA_CHANGED);
publishEvent(ev);
}
示例15: equalsFullExtent
import org.opengis.geometry.Envelope; //导入依赖的package包/类
/**
* Check if the envelope corresponds to full extent. It will probably not
* equal the full extent envelope because of slack space in the display
* area, so we check that at least one pair of opposite edges are equal to
* the full extent envelope, allowing for slack space on the other two
* sides.
* <p>
* Note: this method returns {@code false} if the full extent envelope is
* wholly within the requested envelope (e.g. user has zoomed out from full
* extent), only touches one edge, or touches two adjacent edges. In all
* these cases we assume that the user wants to maintain the slack space in
* the display.
* <p>
* This method is part of the work-around that the map pane needs because of
* the differences in how raster and vector layers are treated by the
* renderer classes.
*
* @param envelope
* a pending display envelope to compare to the full extent
* envelope
*
* @return true if the envelope is coincident with the full extent evenlope
* on at least two edges; false otherwise
*
* @todo My logic here seems overly complex - I'm sure there must be a
* simpler way for the map pane to handle this.
*/
private boolean equalsFullExtent(final Envelope envelope) {
if (fullExtent == null || envelope == null) {
return false;
}
final double TOL = 1.0e-6d * (fullExtent.getWidth() + fullExtent.getHeight());
boolean touch = false;
if (Math.abs(envelope.getMinimum(0) - fullExtent.getMinimum(0)) < TOL) {
touch = true;
}
if (Math.abs(envelope.getMaximum(0) - fullExtent.getMaximum(0)) < TOL) {
if (touch) {
return true;
}
}
if (Math.abs(envelope.getMinimum(1) - fullExtent.getMinimum(1)) < TOL) {
touch = true;
}
if (Math.abs(envelope.getMaximum(1) - fullExtent.getMaximum(1)) < TOL) {
if (touch) {
return true;
}
}
return false;
}