Package org.geotools.grid.hexagon
Class Hexagons
- Object
-
- 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
Constructors Constructor Description Hexagons()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static doubleareaToSideLength(double area)Calculates the side length of a hexagon with the given area.static Hexagoncreate(double minX, double minY, double sideLen, HexagonOrientation orientation, CoordinateReferenceSystem crs)Creates a newHexagonobject.static SimpleFeatureSourcecreateGrid(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 SimpleFeatureSourcecreateGrid(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 doublesideLengthToArea(double sideLen)Calculates the area of a hexagon with the given side length.
-
-
-
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- ifsideLenis 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- ifareais not greater than zero
-
create
public static Hexagon create(double minX, double minY, double sideLen, HexagonOrientation orientation, CoordinateReferenceSystem crs)
Creates a newHexagonobject.- Parameters:
minX- the min X ordinate of the bounding rectangleminY- the min Y ordinate of the bounding rectanglesideLen- the side lengthorientation- eitherHexagon.Orientation.FLATorHexagon.Orientation.ANGLEDcrs- the coordinate reference system (may benull)- Returns:
- a new
Hexagonobject - Throws:
IllegalArgumentException- ifsideLenis<=0 or iforientationisnull
-
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 rectanglesideLen- hexagon side lengthorientation- hexagon orientationgridBuilder- an instance ofGridFeatureBuilder- Returns:
- a new grid
- Throws:
IllegalArgumentException- if bounds is null or empty; or if sideLen is<=0; or if theCoordinateReferenceSystemsset for the bounds and theGridFeatureBuilderare 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 rectanglesideLen- hexagon side lengthvertexSpacing- maximum distance between adjacent vertices in a grid element; if<= 0or>= min(width, height) / 2.0it is ignored and the polygons will not be densifiedorientation- hexagon orientationgridFeatureBuilder- an instance ofGridFeatureBuilder- Returns:
- a new grid
- Throws:
IllegalArgumentException- if bounds is null or empty; or if sideLen is<=0; or if theCoordinateReferenceSystemsset for the bounds and theGridFeatureBuilderare both non-null but different
-
-