本文整理汇总了Java中org.geotools.geometry.jts.ReferencedEnvelope.getSpan方法的典型用法代码示例。如果您正苦于以下问题:Java ReferencedEnvelope.getSpan方法的具体用法?Java ReferencedEnvelope.getSpan怎么用?Java ReferencedEnvelope.getSpan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.geotools.geometry.jts.ReferencedEnvelope
的用法示例。
在下文中一共展示了ReferencedEnvelope.getSpan方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getFootprint
import org.geotools.geometry.jts.ReferencedEnvelope; //导入方法依赖的package包/类
public static Geometry getFootprint(
final ReferencedEnvelope projectedReferenceEnvelope,
final GridCoverage gridCoverage ) {
try {
final Envelope sampleEnvelope = gridCoverage.getEnvelope();
final double avgSpan = (projectedReferenceEnvelope.getSpan(0) + projectedReferenceEnvelope.getSpan(1)) / 2;
final MathTransform gridCrsToWorldCrs = CRS.findMathTransform(
gridCoverage.getCoordinateReferenceSystem(),
GeoWaveGTRasterFormat.DEFAULT_CRS,
true);
final Coordinate[] polyCoords = getWorldCoordinates(
sampleEnvelope.getMinimum(0),
sampleEnvelope.getMinimum(1),
sampleEnvelope.getMaximum(0),
sampleEnvelope.getMaximum(1),
gridCrsToWorldCrs.isIdentity() ? 2 : (int) Math.min(
Math.max(
(avgSpan * MIN_SEGMENTS) / SIMPLIFICATION_MAX_DEGREES,
MIN_SEGMENTS),
MAX_SEGMENTS),
gridCrsToWorldCrs);
final Polygon poly = new GeometryFactory().createPolygon(polyCoords);
if (polyCoords.length > MAX_VERTICES_BEFORE_SIMPLIFICATION) {
final Geometry retVal = DouglasPeuckerSimplifier.simplify(
poly,
SIMPLIFICATION_MAX_DEGREES);
if (retVal.isEmpty()) {
return poly;
}
return retVal;
}
else {
return poly;
}
}
catch (MismatchedDimensionException | TransformException | FactoryException e1) {
LOGGER.warn(
"Unable to calculate grid coverage footprint",
e1);
}
return null;
}
示例3: render
import org.geotools.geometry.jts.ReferencedEnvelope; //导入方法依赖的package包/类
public static BufferedImage render( InternalMap map, Integer maxWidth, Integer maxHeight )
{
MapContent mapContent = new MapContent();
// Convert map objects to features, and add them to the map
for ( InternalMapLayer mapLayer : map.getLayers() )
{
for ( InternalMapObject mapObject : mapLayer.getMapObjects() )
{
mapContent.addLayer( createFeatureLayerFromMapObject( mapObject ) );
}
}
// Create a renderer for this map
GTRenderer renderer = new StreamingRenderer();
renderer.setMapContent( mapContent );
// Calculate image height
ReferencedEnvelope mapBounds = mapContent.getMaxBounds();
double widthToHeightFactor = mapBounds.getSpan( 0 ) / mapBounds.getSpan( 1 );
int[] widthHeight = getWidthHeight( maxWidth, maxHeight, LegendSet.LEGEND_TOTAL_WIDTH, TITLE_HEIGHT, widthToHeightFactor );
//LegendSet.LEGEND_TOTAL_WIDTH;
Rectangle imageBounds = new Rectangle( 0, 0, widthHeight[0], widthHeight[1] );
// Create an image and get the graphics context from it
BufferedImage image = new BufferedImage( imageBounds.width, imageBounds.height, BufferedImage.TYPE_INT_ARGB );
Graphics2D graphics = (Graphics2D) image.getGraphics();
graphics.setRenderingHint( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
renderer.paint( graphics, imageBounds, mapBounds );
mapContent.dispose();
return image;
}