com.pb.lisdk.grid.hexagon

## Class Hexagon

- java.lang.Object
- - com.pb.lisdk.grid.hexagon.Hexagon

All Implemented Interfaces:
  IGridCell, Serializable

    public final class Hexagon
    extends Object
    implements IGridCell, Serializable

A mechanism for bucketing a geographic area (-180, -90, 180, 90) with various levels of precision into hexagons.

### Examples

Determine the hash for the hexagon containing the point (-73.700052, 42.678120) with a level of 10.

              String hash = Hexagon.encode(-73.700052, 42.678120, 10).getHash();

Determine the boundary of the hash "PF7041126164"

              IFeatureGeometry geometry = Hexagon.decode("PF7041126164").asFeatureGeometry();

See Also:
  Serialized Form

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`IFeatureGeometry` `asFeatureGeometry()` Get the cell boundary as a geometry
`static Hexagon` `decode(String hash)` Get the hexagon that corresponds to the specified ID.
`static Hexagon` `encode(double longitude, double latitude, int level)` Get the hexagon that contains the longitude and latitude at the specified level.
`boolean` `equals(Object o)`
`Envelope` `getBounds()` Get the bounds of the grid cell.
`String` `getHash()` Get the well-known string ID for the grid cell.
`int` `getLevel()` Get the level of this hexagon.
`int` `hashCode()`

### Methods inherited from class java.lang.Object

`getClass, notify, notifyAll, toString, wait, wait, wait`

### Method Detail

#### getHash

    public String getHash()

Description copied from interface: `IGridCell`
Get the well-known string ID for the grid cell.

Specified by:
  `getHash` in interface `IGridCell`

#### getBounds

    public Envelope getBounds()

Description copied from interface: `IGridCell`
Get the bounds of the grid cell.

Specified by:
  `getBounds` in interface `IGridCell`

#### asFeatureGeometry

    public IFeatureGeometry asFeatureGeometry()

Description copied from interface: `IGridCell`
Get the cell boundary as a geometry

Specified by:
  `asFeatureGeometry` in interface `IGridCell`

#### equals

    public boolean equals(Object o)

Overrides:
  `equals` in class `Object`

#### hashCode

    public int hashCode()

Overrides:
  `hashCode` in class `Object`

#### getLevel

    public int getLevel()

Get the level of this hexagon.

#### encode

    public static Hexagon encode(double longitude,
                                 double latitude,
                                 int level)

Get the hexagon that contains the longitude and latitude at the specified level. The longitude and latitude are expected to be in the WGS 84 (EPSG:4326) coordinate system.

Parameters:
  `longitude` - The longitude of the point.
  `latitude` - The latitude of the point.
  `level` - The hexagon level. The higher the level, the smaller the hexagon. Must be between 1 and 11
Returns:
  The hexagon that contains the longitude and latitude at the specified level.

#### decode

    public static Hexagon decode(String hash)

Get the hexagon that corresponds to the specified ID.

Parameters:
  `hash` - The unique ID of the hexagon.
Returns:
  The hexagon that corresponds to the specified ID.