org.geotools.grid.hexagon
Class Hexagons

Object
  extended by Hexagons

public class Hexagons
extends Object

A utilities class with static methods to create and work with hexagonal grid elements.

Since:
2.7
Author:
mbedward

Constructor Summary
Hexagons()
           
 
Method Summary
static double areaToSideLength(double area)
          Calculates the side length of a hexagon with the given area.
static Hexagon create(double minX, double minY, double sideLen, HexagonOrientation orientation, CoordinateReferenceSystem crs)
          Creates a new Hexagon object.
static SimpleFeatureSource createGrid(ReferencedEnvelope bounds, double sideLen, double vertexSpacing, HexagonOrientation orientation, GridFeatureBuilder gridFeatureBuilder)
          Creates a new grid of tesselated hexagons within a bounding rectangle with grid elements represented by densified polygons (ie. additional vertices added to each edge).
static SimpleFeatureSource createGrid(ReferencedEnvelope bounds, double sideLen, HexagonOrientation orientation, GridFeatureBuilder gridBuilder)
          Creates a new grid of tesselated hexagons within a bounding rectangle with grid elements represented by simple (ie. undensified) polygons.
static double sideLengthToArea(double sideLen)
          Calculates the area of a hexagon with the given side length.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Hexagons

public Hexagons()
Method Detail

sideLengthToArea

public static double sideLengthToArea(double sideLen)
Calculates the area of a hexagon with the given side length.

Parameters:
sideLen - side length
Returns:
the area
Throws:
IllegalArgumentException - if sideLen is not greater than zero

areaToSideLength

public static double areaToSideLength(double area)
Calculates the side length of a hexagon with the given area.

Parameters:
area - the area
Returns:
the side length
Throws:
IllegalArgumentException - if area is not greater than zero

create

public static Hexagon create(double minX,
                             double minY,
                             double sideLen,
                             HexagonOrientation orientation,
                             CoordinateReferenceSystem crs)
Creates a new Hexagon object.

Parameters:
minX - the min X ordinate of the bounding rectangle
minY - the min Y ordinate of the bounding rectangle
sideLen - the side length
orientation - either Hexagon.Orientation.FLAT or Hexagon.Orientation.ANGLED
crs - the coordinate reference system (may be null)
Returns:
a new Hexagon object
Throws:
IllegalArgumentException - if sideLen is <= 0 or if orientation is null

createGrid

public static SimpleFeatureSource createGrid(ReferencedEnvelope bounds,
                                             double sideLen,
                                             HexagonOrientation orientation,
                                             GridFeatureBuilder gridBuilder)
Creates a new grid of tesselated hexagons within a bounding rectangle with grid elements represented by simple (ie. undensified) polygons.

Parameters:
bounds - the bounding rectangle
sideLen - hexagon side length
orientation - hexagon orientation
gridBuilder - an instance of GridFeatureBuilder
Returns:
a new grid
Throws:
IllegalArgumentException - if bounds is null or empty; or if sideLen is <= 0; or if the CoordinateReferenceSystems set for the bounds and the GridFeatureBuilder are both non-null but different

createGrid

public static SimpleFeatureSource createGrid(ReferencedEnvelope bounds,
                                             double sideLen,
                                             double vertexSpacing,
                                             HexagonOrientation orientation,
                                             GridFeatureBuilder gridFeatureBuilder)
Creates a new grid of tesselated hexagons within a bounding rectangle with grid elements represented by densified polygons (ie. additional vertices added to each edge).

Parameters:
bounds - the bounding rectangle
sideLen - hexagon side length
vertexSpacing - maximum distance between adjacent vertices in a grid element; if <= 0 or >= min(width, height) / 2.0 it is ignored and the polygons will not be densified
orientation - hexagon orientation
gridFeatureBuilder - an instance of GridFeatureBuilder
Returns:
a new grid
Throws:
IllegalArgumentException - if bounds is null or empty; or if sideLen is <= 0; or if the CoordinateReferenceSystems set for the bounds and the GridFeatureBuilder are both non-null but different


Copyright © 1996-2014 Geotools. All Rights Reserved.