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 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 newHexagon
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.
-
-
-
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
- ifsideLen
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
- ifarea
is not greater than zero
-
create
public static Hexagon create(double minX, double minY, double sideLen, HexagonOrientation orientation, CoordinateReferenceSystem crs)
Creates a newHexagon
object.- Parameters:
minX
- the min X ordinate of the bounding rectangleminY
- the min Y ordinate of the bounding rectanglesideLen
- the side lengthorientation
- eitherHexagon.Orientation.FLAT
orHexagon.Orientation.ANGLED
crs
- the coordinate reference system (may benull
)- Returns:
- a new
Hexagon
object - Throws:
IllegalArgumentException
- ifsideLen
is<=
0 or iforientation
isnull
-
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 theCoordinateReferenceSystems
set for the bounds and theGridFeatureBuilder
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 rectanglesideLen
- hexagon side lengthvertexSpacing
- 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 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 theCoordinateReferenceSystems
set for the bounds and theGridFeatureBuilder
are both non-null but different
-
-