com.pb.lisdk.grid.square

## Class Square

- java.lang.Object
- - com.pb.lisdk.grid.square.Square

All Implemented Interfaces:
  IGridCell, Serializable

    public final class Square
    extends Object
    implements IGridCell, Serializable

A square hash is a mechanism for bucketing a geographic area (-180, -90, 180, 90) with various levels of precision in a way that the cells appear square when viewed in Popular Mercator (EPSG:3857).

### Examples

Determine the hash for the square containing the point (-73.700052, 42.678120) with a precision of 10 characters

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

Determine the bounds of the hash "0302323112"

              Envelope bounds = Square.decode("0302323112").getBounds();

See Also:
  Serialized Form

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods
`IFeatureGeometry` `asFeatureGeometry()` Get the cell boundary as a geometry
`static Square` `decode(String hash)` Determine the square hash for the specified well-known string ID.
`static Square` `encode(double longitude, double latitude, int level)` Determine the cell that contains the specified point at the specified precision.
`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` `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`

#### encode

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

Determine the cell that contains the specified point at the specified precision.

Parameters:
  `longitude` - The longitude value for the specified point.
  `latitude` - The latitude value for the specified point.
  `level` - The length of the string key to be returned. The longer the string, the higher the precision (i.e. smaller the square).

#### decode

    public static Square decode(String hash)

Determine the square hash for the specified well-known string ID.

Parameters:
  `hash` - The well-known string ID.
Returns:
  A representation of the square hash.