org.geotools.grid
Class Envelopes

Object
  extended by Envelopes

public class Envelopes
extends Object

A helper class to create bounding envelopes with width and height that are simple multiples of a given resolution.


 // Example of use: creating an envlope with 'neat' lat-lon bounds
 // that encompasses a set of features

 SimpleFeatureSource featureSource = ...
 ReferencedEnvelope featureBounds = featureSource.getBounds();
 ReferencedEnvelope latLonEnv = featureBounds.transform(DefaultGeographicCRS.WGS84, true);

 // 1 degree grid resoluation
 final double gridSize = 1.0;
 ReferencedEnvelope gridBounds = Envelopes.expandToInclude(latLonEnv, gridSize);
 

Since:
2.7
Author:
mbedward

Constructor Summary
Envelopes()
           
 
Method Summary
static ReferencedEnvelope expandToInclude(ReferencedEnvelope srcEnv, double resolution)
          Include the provided envelope, expanding as necessary and rounding the bounding coordinates such that they are multiples of the specified resolution.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Envelopes

public Envelopes()
Method Detail

expandToInclude

public static ReferencedEnvelope expandToInclude(ReferencedEnvelope srcEnv,
                                                 double resolution)
Include the provided envelope, expanding as necessary and rounding the bounding coordinates such that they are multiples of the specified resolution. For example, if resolution is 100 then the min and max bounding coordinates of this envelope will set to mutliples of 100 by rounding down the min values and rounding up the max values if required.

 // Example, create a new envelope that cntains an input envlope and
 // whose boundind coordinates are multiples of 100
 //
 ReferencedEnvelope inputEnv = ...
 ReferencedEnvelope roundedEnv = new ReferencedEnvelope();
 roundedEnv.expandToInclude(inputEnv, 100);
 

Parameters:
srcEnv - the envelope to include
resolution - resolution (in world distance units) of the resulting boundary coordinates
Returns:
a new envelope with 'rounded' bounding coordinates


Copyright © 1996-2014 Geotools. All Rights Reserved.