本文整理汇总了Java中org.geotools.geometry.jts.ReferencedEnvelope类的典型用法代码示例。如果您正苦于以下问题:Java ReferencedEnvelope类的具体用法?Java ReferencedEnvelope怎么用?Java ReferencedEnvelope使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ReferencedEnvelope类属于org.geotools.geometry.jts包,在下文中一共展示了ReferencedEnvelope类的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: expandBounds
import org.geotools.geometry.jts.ReferencedEnvelope; //导入依赖的package包/类
/**
* Expands inBounds by multiplying min of inBounds.getWidth and inBounds.getHeight times percent
*
* @param inBounds
* @param percent
* @return
*/
public static Bounds expandBounds(Bounds inBounds, String inCRS, double percent) {
try {
double ulx = inBounds.getLeft();
double uly = inBounds.getTop();
double lrx = inBounds.getRight();
double lry = inBounds.getBottom();
CoordinateReferenceSystem theCRS = CRS.decode(inCRS);
ReferencedEnvelope re = new ReferencedEnvelope(ulx, lrx, lry, uly, theCRS);
double expandBy = Math.min(re.getHeight(), re.getWidth()) * percent;
re.expandBy(expandBy);
return getBounds(re.toBounds(theCRS));
} catch (Exception e) {
}
return null;
}
示例3: read
import org.geotools.geometry.jts.ReferencedEnvelope; //导入依赖的package包/类
public void read(URL file) throws IOException {
Map<String, Object> map = new HashMap<>();
map.put("url", file);
DataStore dataStore = DataStoreFinder.getDataStore(map);
String typeName = dataStore.getTypeNames()[0];
FeatureSource<SimpleFeatureType, SimpleFeature> source = dataStore.getFeatureSource(typeName);
FeatureCollection<SimpleFeatureType, SimpleFeature> collection = source.getFeatures();
FeatureIterator<SimpleFeature> features = collection.features();
int count = 0;
LOGGER.info("reading world time zones ...");
while (features.hasNext()) {
count++;
SimpleFeature feature = features.next();
ReferencedEnvelope referencedEnvelope = new ReferencedEnvelope(feature.getBounds());
quadtree.insert(referencedEnvelope,feature);
}
LOGGER.info(count + " features read");
}
示例4: parse
import org.geotools.geometry.jts.ReferencedEnvelope; //导入依赖的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;
}
}
示例5: resizeSwingContent
import org.geotools.geometry.jts.ReferencedEnvelope; //导入依赖的package包/类
/**
* Resizes swing content and centers map.
* @param width The new content width.
*/
public void resizeSwingContent(double width) {
try {
if (width >= mapWidth) {
double oldWidth = mapPane.getWidth();
this.mapNode.resize(width - MAP_NODE_MARGIN, mapHeight);
double scale = mapPane.getWorldToScreenTransform().getScaleX();
ReferencedEnvelope bounds = mapPane.getDisplayArea();
double dXScreenCoord = (width - MAP_NODE_MARGIN - oldWidth) / 2;
double dXWorldCoord = dXScreenCoord / scale;
bounds.translate(-1 * dXWorldCoord , 0);
mapPane.setDisplayArea(bounds);
mapPane.deleteGraphics();
clearCoordinateDisplay();
}
} catch (NullPointerException e) { }
}
示例6: 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;
}
示例7: calcAoi
import org.geotools.geometry.jts.ReferencedEnvelope; //导入依赖的package包/类
private void calcAoi() throws NoninvertibleTransformException {
Point2D.Double[] pts = new Point2D.Double[4];
pts[0] = new Point2D.Double(tileCenter.x - tileHalf, tileCenter.y - tileHalf);
pts[1] = new Point2D.Double(tileCenter.x + tileHalf, tileCenter.y - tileHalf);
pts[2] = new Point2D.Double(tileCenter.x - tileHalf, tileCenter.y + tileHalf);
pts[3] = new Point2D.Double(tileCenter.x + tileHalf, tileCenter.y + tileHalf);
cartesian2ScreenTransform.inverseTransform(pts[0], pts[0]);
cartesian2ScreenTransform.inverseTransform(pts[1], pts[1]);
cartesian2ScreenTransform.inverseTransform(pts[2], pts[2]);
cartesian2ScreenTransform.inverseTransform(pts[3], pts[3]);
double x1 = Double.MAX_VALUE;
double x2 = -Double.MAX_VALUE;
double y1 = Double.MAX_VALUE;
double y2 = -Double.MAX_VALUE;
for (Point2D.Double pt : pts) {
x1 = Math.min(x1, pt.x);
y1 = Math.min(y1, pt.y);
x2 = Math.max(x2, pt.x);
y2 = Math.max(y2, pt.y);
}
tileAoi = new ReferencedEnvelope(x1, x2, y1, y2, mapDisplayContextCrs);
}
示例8: getEnvelope
import org.geotools.geometry.jts.ReferencedEnvelope; //导入依赖的package包/类
/**
* Get the current data envelope.
*
* @param connection the db connection.
* @return the envelope.
* @throws Exception
*/
public static ReferencedEnvelope getEnvelope( IHMConnection connection ) throws Exception {
String query = "SELECT min(" + //
ImageTableFields.COLUMN_LON.getFieldName() + "), max(" + //
ImageTableFields.COLUMN_LON.getFieldName() + "), min(" + //
ImageTableFields.COLUMN_LAT.getFieldName() + "), max(" + //
ImageTableFields.COLUMN_LAT.getFieldName() + ") " + //
" FROM " + TABLE_IMAGES;
try (IHMStatement statement = connection.createStatement(); IHMResultSet rs = statement.executeQuery(query);) {
if (rs.next()) {
double minX = rs.getDouble(1);
double maxX = rs.getDouble(2);
double minY = rs.getDouble(3);
double maxY = rs.getDouble(4);
ReferencedEnvelope env = new ReferencedEnvelope(minX, maxX, minY, maxY, DefaultGeographicCRS.WGS84);
return env;
}
}
return null;
}
示例9: 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();
}
}
示例10: 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;
}
示例11: FeatureLayer
import org.geotools.geometry.jts.ReferencedEnvelope; //导入依赖的package包/类
public FeatureLayer(LayerType layerType, final FeatureCollection<SimpleFeatureType, SimpleFeature> fc,
PropertySet configuration) {
super(layerType, configuration);
crs = fc.getSchema().getGeometryDescriptor().getCoordinateReferenceSystem();
if (crs == null) {
// todo - check me! Why can this happen??? (nf)
crs = DefaultGeographicCRS.WGS84;
}
final ReferencedEnvelope envelope = new ReferencedEnvelope(fc.getBounds(), crs);
modelBounds = new Rectangle2D.Double(envelope.getMinX(), envelope.getMinY(),
envelope.getWidth(), envelope.getHeight());
mapContext = new DefaultMapContext(crs);
final Style style = (Style) configuration.getValue(FeatureLayerType.PROPERTY_NAME_SLD_STYLE);
mapContext.addLayer(fc, style);
renderer = new StreamingRenderer();
workaroundLabelCacheBug();
style.accept(new RetrievingStyleVisitor());
renderer.setContext(mapContext);
}
示例12: getWorldtoScreen
import org.geotools.geometry.jts.ReferencedEnvelope; //导入依赖的package包/类
public static Point2D getWorldtoScreen(double x, double y){
Rectangle imageBounds=null;
ReferencedEnvelope mapBounds=null;
try{
// mapBounds=map.getLayerBounds();
imageBounds = mapFrame.getBounds();
int width = (int)imageBounds.getWidth();
int height = (int)imageBounds.getHeight();
}catch(Exception e){
}
AffineTransform world2screen =
RendererUtilities.worldToScreenTransform(mapBounds, imageBounds);
Point2D pointScreenAbsolute = new Point2D.Double(x, y);
Point2D pointScreen = world2screen.transform(pointScreenAbsolute, null);
return pointScreen;
}
示例13: getScreentoWorld
import org.geotools.geometry.jts.ReferencedEnvelope; //导入依赖的package包/类
public static Point2D getScreentoWorld(double x, double y) throws Exception {
Rectangle imageBounds=null;
ReferencedEnvelope mapBounds=null;
try{
// mapBounds=map.getLayerBounds();
imageBounds = mapFrame.getBounds();
int width = (int)imageBounds.getWidth();
int height = (int)imageBounds.getHeight();
}catch(Exception e){
}
AffineTransform world2screen =
RendererUtilities.worldToScreenTransform(mapBounds, imageBounds);
AffineTransform screen2world = world2screen.createInverse();
Point2D pointScreenAbsolute = new Point2D.Double(x, y);
Point2D pointScreen = screen2world.transform(pointScreenAbsolute, null);
return pointScreen;
}
示例14: afterTransactionInternal
import org.geotools.geometry.jts.ReferencedEnvelope; //导入依赖的package包/类
private void afterTransactionInternal(final TransactionType transaction, boolean committed) {
log.fine("Detected change to data, updating bounds of affected featuer types and layer groups");
final Map<Name, Collection<ReferencedEnvelope>> byLayerDirtyRegions = getByLayerDirtyRegions(transaction);
if (byLayerDirtyRegions.isEmpty()) {
return;
}
byLayerDirtyRegions.entrySet().stream().forEach(e->{
FeatureTypeInfo fti = catalog.getFeatureTypeByName(e.getKey());
try{
merge(fti.getNativeBoundingBox(), e.getValue()).ifPresent(dirtyRegion->{
// Update the feature type
updateFeatureType(fti, dirtyRegion);
// Update all the layer groups that use it, directly or indirectly
StreamSupport.stream(getLayerGroupsFor(fti).spliterator(), false)
.forEach(lgi->updateLayerGroup(lgi, dirtyRegion));
});
} catch (Exception ex) {
log.log(Level.WARNING, ex.getMessage(), ex);
return;
}
});
}
示例15: merge
import org.geotools.geometry.jts.ReferencedEnvelope; //导入依赖的package包/类
private Optional<ReferencedEnvelope> merge(final ReferencedEnvelope oldEnv,
final Collection<ReferencedEnvelope> dirtyList) {
final CoordinateReferenceSystem declaredCrs = oldEnv.getCoordinateReferenceSystem();
return dirtyList.stream()
.map(env->{
if(env instanceof ReferencedEnvelope3D) {
return new ReferencedEnvelope(env, CRS.getHorizontalCRS(env.getCoordinateReferenceSystem()));
} else {
return env;
}
})
.map(env->{
try {
return env.transform(declaredCrs, true, 1000);
} catch (TransformException | FactoryException e) {
throw new RuntimeException("Error while merging bounding boxes",e);
}
})
.reduce((env1, env2)->{ReferencedEnvelope x = new ReferencedEnvelope(env1); x.expandToInclude(env2); return x;});
}