本文整理汇总了Java中org.geotools.geometry.jts.ReferencedEnvelope.transform方法的典型用法代码示例。如果您正苦于以下问题:Java ReferencedEnvelope.transform方法的具体用法?Java ReferencedEnvelope.transform怎么用?Java ReferencedEnvelope.transform使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.geotools.geometry.jts.ReferencedEnvelope
的用法示例。
在下文中一共展示了ReferencedEnvelope.transform方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setExtend
import org.geotools.geometry.jts.ReferencedEnvelope; //导入方法依赖的package包/类
/**
* sets the viewport of the map to the given extend.
*
* @param envelope the extend
*/
public void setExtend(ReferencedEnvelope envelope) {
try {
envelope = envelope.transform(this.mapContent.getViewport()
.getCoordinateReferenceSystem(), true);
double xLength = envelope.getSpan(0);
xLength = xLength * TEN_PERCENT;
double yLength = envelope.getSpan(1);
yLength = yLength * TEN_PERCENT;
envelope.expandBy(xLength, yLength);
bboxAction.resetCoordinates();
mapPane.deleteGraphics();
mapPane.setDisplayArea(envelope);
} catch (FactoryException | TransformException e) {
log.log(Level.SEVERE, e.getMessage(), e);
}
}
示例2: createSearchEnv
import org.geotools.geometry.jts.ReferencedEnvelope; //导入方法依赖的package包/类
private ReferencedEnvelope createSearchEnv(final DirectPosition2D pos, final double radius) {
final CoordinateReferenceSystem contextCRS = getMapContent().getCoordinateReferenceSystem();
ReferencedEnvelope env = new ReferencedEnvelope(pos.x - radius, pos.x + radius, pos.y - radius, pos.y + radius,
contextCRS);
if (isTransformRequired()) {
final Layer layer = layerRef.get();
if (layer != null) {
final CoordinateReferenceSystem layerCRS = layer.getFeatureSource().getSchema()
.getCoordinateReferenceSystem();
try {
env = env.transform(layerCRS, true);
} catch (final Exception ex) {
throw new IllegalStateException(ex);
}
}
}
return env;
}
示例3: RasterizedSpatialiteLasLayer
import org.geotools.geometry.jts.ReferencedEnvelope; //导入方法依赖的package包/类
public RasterizedSpatialiteLasLayer( String title, ASpatialDb db, Integer tileSize, boolean transparentBackground,
boolean doIntensity ) throws Exception {
super(makeLevels(title, tileSize, transparentBackground, db, doIntensity));
String plus = doIntensity ? INTENSITY : ELEVATION;
this.layerName = title + " " + plus;
this.setUseTransparentTextures(true);
try {
Envelope tableBounds = db.getTableBounds(LasSourcesTable.TABLENAME);
GeometryColumn spatialiteGeometryColumns = db.getGeometryColumnsForTable(LasCellsTable.TABLENAME);
CoordinateReferenceSystem dataCrs = CRS.decode("EPSG:" + spatialiteGeometryColumns.srid);
CoordinateReferenceSystem targetCRS = DefaultGeographicCRS.WGS84;
ReferencedEnvelope env = new ReferencedEnvelope(tableBounds, dataCrs);
ReferencedEnvelope envLL = env.transform(targetCRS, true);
centre = envLL.centre();
} catch (Exception e) {
e.printStackTrace();
centre = CrsUtilities.WORLD.centre();
}
}
示例4: getBoundaryProduct
import org.geotools.geometry.jts.ReferencedEnvelope; //导入方法依赖的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;
}
示例5: computeMosaicBounds
import org.geotools.geometry.jts.ReferencedEnvelope; //导入方法依赖的package包/类
/**
* STEP 3 methods
*/
private ReferencedEnvelope computeMosaicBounds() {
final Rectangle2D initialBounds = new Rectangle2D.Double();
initialBounds.setFrameFromDiagonal(this.westBound, this.southBound, this.eastBound, this.northBound);
final ReferencedEnvelope boundsEnvelope = new ReferencedEnvelope(initialBounds, DefaultGeographicCRS.WGS84);
try {
return boundsEnvelope.transform(this.targetCRS, true);
} catch (TransformException | FactoryException e) {
throw new OperatorException(e);
}
}
示例6: workaround
import org.geotools.geometry.jts.ReferencedEnvelope; //导入方法依赖的package包/类
public static ReferencedEnvelope workaround(ReferencedEnvelope env, CoordinateReferenceSystem targetCRS) throws TransformException, FactoryException{
if (targetCRS != null) {
return env.transform(targetCRS, true);
} else{
return env.transform(CRS.decode(defaultValue), true);
}
}
示例7: expandToIncludeEnvelope
import org.geotools.geometry.jts.ReferencedEnvelope; //导入方法依赖的package包/类
private void expandToIncludeEnvelope( ReferencedEnvelope maxExtent, org.opengis.geometry.Envelope envelope ) {
ReferencedEnvelope tmpExtent = new ReferencedEnvelope(envelope.getCoordinateReferenceSystem());
DirectPosition ll = envelope.getLowerCorner();
double[] coordinate = ll.getCoordinate();
tmpExtent.expandToInclude(new Coordinate(coordinate[0], coordinate[1]));
DirectPosition ur = envelope.getUpperCorner();
coordinate = ur.getCoordinate();
tmpExtent.expandToInclude(new Coordinate(coordinate[0], coordinate[1]));
try {
ReferencedEnvelope transformed = tmpExtent.transform(maxExtent.getCoordinateReferenceSystem(), true);
maxExtent.expandToInclude(transformed);
} catch (TransformException | FactoryException e) {
e.printStackTrace();
}
}
示例8: ImageMosaicNwwLayer
import org.geotools.geometry.jts.ReferencedEnvelope; //导入方法依赖的package包/类
public ImageMosaicNwwLayer( File imageMosaicShpFile, Integer tileSize, GeneralParameterValue[] gp,
boolean removeSameColorImages ) throws Exception {
super(makeLevels(imageMosaicShpFile, getRenderer(imageMosaicShpFile, gp), tileSize, removeSameColorImages));
this.layerName = FileUtilities.getNameWithoutExtention(imageMosaicShpFile);
ReferencedEnvelope envelope = OmsVectorReader.readEnvelope(imageMosaicShpFile.getAbsolutePath());
ReferencedEnvelope envelopeLL = envelope.transform(DefaultGeographicCRS.WGS84, true);
double w = envelopeLL.getMinX();
double s = envelopeLL.getMinY();
double e = envelopeLL.getMaxX();
double n = envelopeLL.getMaxY();
double centerX = w + (e - w) / 2.0;
double centerY = s + (n - s) / 2.0;
centerCoordinate = new Coordinate(centerX, centerY);
this.setUseTransparentTextures(true);
}
示例9: click1
import org.geotools.geometry.jts.ReferencedEnvelope; //导入方法依赖的package包/类
SimpleFeatureCollection click1(MapMouseEvent ev) throws Exception {
// Construct a 3x3 pixel rectangle centred on the mouse click position
java.awt.Point screenPos = ev.getPoint();
Rectangle screenRect = new Rectangle(screenPos.x - 1, screenPos.y - 1, 3, 3);
CoordinateReferenceSystem worldCRS = mapFrame.getMapContent().getCoordinateReferenceSystem();
// Transform the screen rectangle into a bounding box in the
// coordinate reference system of our map content.
AffineTransform screenToWorld = mapFrame.getMapPane().getScreenToWorldTransform();
Rectangle2D worldRect = screenToWorld.createTransformedShape(screenRect).getBounds2D();
ReferencedEnvelope worldBBox = new ReferencedEnvelope(worldRect, worldCRS);
// transform from world to target CRS
SimpleFeatureType schema = featureSource.getSchema();
CoordinateReferenceSystem targetCRS = schema.getCoordinateReferenceSystem();
String geometryAttributeName = schema.getGeometryDescriptor().getLocalName();
ReferencedEnvelope bbox = worldBBox.transform(targetCRS, true, 10);
FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2();
// Option 1 BBOX
Filter filter = ff.bbox(ff.property(geometryAttributeName), bbox);
// Option 2 Intersects
// Filter filter = ff.intersects(ff.property(geometryAttributeName), ff.literal(bbox));
return featureSource.getFeatures(filter);
}
示例10: transformReferencedEnvelope
import org.geotools.geometry.jts.ReferencedEnvelope; //导入方法依赖的package包/类
private void transformReferencedEnvelope() throws Exception {
// transformReferencedEnvelope start
CoordinateReferenceSystem sourceCRS = CRS.decode("EPSG:4326");
ReferencedEnvelope envelope = new ReferencedEnvelope(0, 10, 0, 20, sourceCRS);
// Transform using 10 sample points around the envelope
CoordinateReferenceSystem targetCRS = CRS.decode("EPSG:23032");
ReferencedEnvelope result = envelope.transform(targetCRS, true, 10);
// transformReferencedEnvelope end
}
示例11: getReferenceEnvelope
import org.geotools.geometry.jts.ReferencedEnvelope; //导入方法依赖的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;
}
示例12: initalize
import org.geotools.geometry.jts.ReferencedEnvelope; //导入方法依赖的package包/类
public GeoHashGrid initalize(ReferencedEnvelope srcEnvelope, SimpleFeatureCollection features) throws NoSuchAuthorityCodeException, TransformException, FactoryException {
this.buckets = readFeatures(features);
final String firstGeohash = buckets.isEmpty() ? null : (String) buckets.get(0).get("key");
final int precision;
if (firstGeohash == null || !isValid(firstGeohash)) {
LOGGER.fine("No aggregations found or missing/invalid geohash key");
precision = DEFAULT_PRECISION;
} else {
precision = ((String) buckets.get(0).get("key")).length();
}
cellWidth = GeoHash.widthDegrees(precision);
cellHeight = GeoHash.heightDegrees(precision);
if (srcEnvelope.getCoordinateReferenceSystem() != null) {
srcEnvelope = srcEnvelope.transform(DefaultGeographicCRS.WGS84,false);
}
computeMinLonOffset(srcEnvelope);
envelope = computeEnvelope(srcEnvelope, precision);
boundingBox = new ReferencedEnvelope(envelope.getMinX()-cellWidth/2.0, envelope.getMaxX()+cellWidth/2.0,
envelope.getMinY()-cellHeight/2.0, envelope.getMaxY()+cellHeight/2.0, DefaultGeographicCRS.WGS84);
final int numCol = (int) Math.round((envelope.getMaxX()-envelope.getMinX())/cellWidth+1);
final int numRow = (int) Math.round((envelope.getMaxY()-envelope.getMinY())/cellHeight+1);
grid = new float[numRow][numCol];
LOGGER.fine("Created grid with size (" + numCol + ", " + numRow + ")");
if (emptyCellValue != 0) {
for (float[] row: grid)
Arrays.fill(row, emptyCellValue);
}
List<GridCell> cells = new ArrayList<>();
buckets.stream().forEach(bucket -> {
Number rasterValue = computeCellValue(bucket);
cells.add(new GridCell((String) bucket.get("key"), rasterValue));
scale.prepareScale(rasterValue.floatValue());
});
cells.stream().forEach(cell -> updateGrid(cell.getGeohash(), cell.getValue()));
LOGGER.fine("Read " + cells.size() + " aggregation buckets");
return this;
}
示例13: getBoundaryProduct
import org.geotools.geometry.jts.ReferencedEnvelope; //导入方法依赖的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("Multi-seize 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;
}
示例14: readAndReprojectBounds
import org.geotools.geometry.jts.ReferencedEnvelope; //导入方法依赖的package包/类
public static ReferencedEnvelope readAndReprojectBounds( String path ) throws Exception {
ReferencedEnvelope env = OmsVectorReader.readEnvelope(path);
return env.transform(GPS_CRS, true);
}
示例15: invertQuery
import org.geotools.geometry.jts.ReferencedEnvelope; //导入方法依赖的package包/类
public Query invertQuery(
@DescribeParameter(name = "outputBBOX", description = "Georeferenced bounding box of the output") ReferencedEnvelope envelope,
Query targetQuery, GridGeometry targetGridGeometry
) throws ProcessException {
final BBOXRemovingFilterVisitor visitor = new BBOXRemovingFilterVisitor();
Filter filter = (Filter) targetQuery.getFilter().accept(visitor, null);
final String geometryName = visitor.getGeometryPropertyName();
if (geometryName != null) {
final BBOX bbox;
try {
if (envelope.getCoordinateReferenceSystem() != null) {
envelope = envelope.transform(DefaultGeographicCRS.WGS84,false);
}
bbox = FILTER_FACTORY.bbox(geometryName, envelope.getMinX(), envelope.getMinY(), envelope.getMaxX(), envelope.getMaxY(), "EPSG:4326");
} catch (Exception e) {
throw new ProcessException("Unable to create bbox filter for feature source", e);
}
filter = (Filter) FILTER_FACTORY.and(filter, bbox).accept(new SimplifyingFilterVisitor(), null);
targetQuery.setFilter(filter);
}
final List<PropertyName> properties = new ArrayList<>();
properties.add(FILTER_FACTORY.property("_aggregation"));
targetQuery.setProperties(properties);
return targetQuery;
}