Package org.geotools.grid.hexagon
Class HexagonBuilder
- Object
-
- PolygonBuilder
-
- HexagonBuilder
-
public class HexagonBuilder extends PolygonBuilder
Used byHexagonsclass to build grids.- Since:
- 2.7
- Author:
- mbedward
-
-
Field Summary
-
Fields inherited from class PolygonBuilder
gridBounds
-
-
Constructor Summary
Constructors Constructor Description HexagonBuilder(ReferencedEnvelope gridBounds, double sideLen, HexagonOrientation orientation)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HexagoncreateNeighbor(PolygonElement el, Neighbor neighbor)Creates a newHexagonpositioned at the given neighbor position relative to the reference element.PolygonElementgetFirstElement()PolygonElementgetNextXElement(PolygonElement el)PolygonElementgetNextYElement(PolygonElement el)booleanisValidDenseVertexSpacing(double v)booleanisValidNeighbor(Neighbor neighbor)Tests whether a neighbor position is valid for a given orientation.-
Methods inherited from class PolygonBuilder
buildGrid
-
-
-
-
Constructor Detail
-
HexagonBuilder
public HexagonBuilder(ReferencedEnvelope gridBounds, double sideLen, HexagonOrientation orientation)
-
-
Method Detail
-
isValidNeighbor
public boolean isValidNeighbor(Neighbor neighbor)
Tests whether a neighbor position is valid for a given orientation. Since theHexagonclass is intended to work within a grid (ie. a perfect tesselation) some combinations of neighbour position and hexagon orientation are invalid. For example, aFLAThexagon does not have aLEFT, rather it hasUPPER_LEFTandLOWER_LEFT.- Specified by:
isValidNeighborin classPolygonBuilder- Parameters:
neighbor- neighbor position- Returns:
trueif the combination is valid;falseotherwise
-
createNeighbor
public Hexagon createNeighbor(PolygonElement el, Neighbor neighbor)
Creates a newHexagonpositioned at the given neighbor position relative to the reference element.- Specified by:
createNeighborin classPolygonBuilder- Parameters:
el- the reference hexagonneighbor- a valid neighbour position given the reference hexagon's orientation- Returns:
- a new
Hexagonobject - Throws:
IllegalArgumentException- if either argument isnullor ifelis not an instance ofHexagonor if the neighbor position is not valid for the reference hexagon's orientation- See Also:
#isValidNeighbor(Hexagon.Orientation, Hexagon.Neighbor)
-
getFirstElement
public PolygonElement getFirstElement()
- Specified by:
getFirstElementin classPolygonBuilder
-
getNextXElement
public PolygonElement getNextXElement(PolygonElement el)
- Specified by:
getNextXElementin classPolygonBuilder
-
getNextYElement
public PolygonElement getNextYElement(PolygonElement el)
- Specified by:
getNextYElementin classPolygonBuilder
-
isValidDenseVertexSpacing
public boolean isValidDenseVertexSpacing(double v)
- Specified by:
isValidDenseVertexSpacingin classPolygonBuilder
-
-