Class H3

java.lang.Object
org.elasticsearch.h3.H3

public final class H3 extends Object
Defines the public API of the H3 library.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    max H3 resolution; H3 version 1 has 16 resolutions, numbered 0 through 15
  • Constructor Summary

    Constructors
    Constructor
    Description
    H3()
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    areNeighborCells(long origin, long destination)
    returns whether or not the provided hexagons border
    static boolean
    areNeighborCells(String origin, String destination)
    returns whether or not the provided hexagons border
    static long
    childPosToH3(long h3, int childPos)
    Returns the child cell at the given position
    static String
    childPosToH3(String h3Address, int childPos)
    Returns the child address at the given position
    static long
    geoToH3(double lat, double lng, int res)
    Find the H3 index of the resolution res cell containing the lat/lon (in degrees)
    static String
    geoToH3Address(double lat, double lng, int res)
    Find the H3 index of the resolution res cell containing the lat/lon (in degrees)
    static long[]
    Return all base cells
    static int
    getResolution(long h3)
    returns the resolution of the provided H3 cell
    static int
    getResolution(String h3Address)
    returns the resolution of the provided H3 cell in string format
    static String[]
    Return all base cells
    static boolean
    h3IsValid(long h3)
    Returns true if this is a valid H3 index
    static boolean
    h3IsValid(String h3Address)
    Returns true if this is a valid H3 index
    static long[]
    h3ToChildren(long h3)
    Returns the children of the given index.
    static String[]
    h3ToChildren(String h3Address)
    Transforms a list of H3 indexes in long form to a list of H3 indexes in string form.
    static int
    h3ToChildrenSize returns the exact number of children
    static long
    h3ToChildrenSize(long h3, int childRes)
    h3ToChildrenSize returns the exact number of children for a cell at a given child resolution.
    static int
    h3ToChildrenSize returns the exact number of children
    static long
    h3ToChildrenSize(String h3Address, int childRes)
    h3ToChildrenSize returns the exact number of children for a h3 affress at a given child resolution.
    h3ToGeoBoundary(long h3)
    Find the cell CellBoundary coordinates for the cell
    Find the cell CellBoundary coordinates for the cell
    static LatLng
    h3ToLatLng(long h3)
    Find the LatLng center point of the cell.
    static LatLng
    h3ToLatLng(String h3Address)
    Find the LatLng center point of the cell.
    static long[]
    Returns the h3 bins on the level below which are not children of the given H3 index but intersects with it.
    static String[]
    Returns the h3 addresses on the level below which are not children of the given H3 address but intersects with it.
    static int
    h3ToNotIntersectingChildrenSize returns the exact number of children intersecting the given parent but not part of the children set.
    static int
    h3ToNotIntersectingChildrenSize returns the exact number of children intersecting the given parent but not part of the children set.
    static long
    h3ToParent(long h3)
    Returns the parent of the given index.
    static String
    h3ToParent(String h3Address)
    Returns the parent of the given index.
    static String
    h3ToString(long h3)
    Converts from long representation of an index to String representation.
    static long[]
    hexRing(long h3)
    Returns the neighbor indexes.
    static String[]
    hexRing(String h3Address)
    Returns the neighbor indexes.
    static long
    hexRingPosToH3(long h3, int ringPos)
    Returns the neighbor index at the given position.
    static String
    hexRingPosToH3(String h3Address, int ringPos)
    Returns the neighbor index at the given position.
    static int
    hexRingSize(long h3)
    Returns the number of neighbor indexes.
    static int
    hexRingSize(String h3Address)
    Returns the number of neighbor indexes.
    static boolean
    isPentagon(long h3)
    determines if an H3 cell is a pentagon
    static boolean
    isPentagon(String h3Address)
    determines if an H3 cell in string format is a pentagon
    static long
    noChildIntersectingPosToH3(long h3, int childPos)
    Returns the no child intersecting cell at the given position
    static String
    noChildIntersectingPosToH3(String h3Address, int childPos)
    Returns the no child intersecting cell at the given position
    static long
    northPolarH3(int res)
    Find the h3 index containing the North Pole at the given resolution.
    static String
    Find the h3 address containing the North Pole at the given resolution.
    static long
    southPolarH3(int res)
    Find the h3 index containing the South Pole at the given resolution.
    static String
    Find the h3 address containing the South Pole at the given resolution.
    static long
    stringToH3(String h3Address)
    Converts from String representation of an index to long representation.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MAX_H3_RES

      public static final int MAX_H3_RES
      max H3 resolution; H3 version 1 has 16 resolutions, numbered 0 through 15
      See Also:
  • Constructor Details

    • H3

      public H3()
  • Method Details

    • h3ToString

      public static String h3ToString(long h3)
      Converts from long representation of an index to String representation.
    • stringToH3

      public static long stringToH3(String h3Address)
      Converts from String representation of an index to long representation.
    • getResolution

      public static int getResolution(long h3)
      returns the resolution of the provided H3 cell
    • getResolution

      public static int getResolution(String h3Address)
      returns the resolution of the provided H3 cell in string format
    • isPentagon

      public static boolean isPentagon(long h3)
      determines if an H3 cell is a pentagon
    • isPentagon

      public static boolean isPentagon(String h3Address)
      determines if an H3 cell in string format is a pentagon
    • h3IsValid

      public static boolean h3IsValid(long h3)
      Returns true if this is a valid H3 index
    • h3IsValid

      public static boolean h3IsValid(String h3Address)
      Returns true if this is a valid H3 index
    • getLongRes0Cells

      public static long[] getLongRes0Cells()
      Return all base cells
    • getStringRes0Cells

      public static String[] getStringRes0Cells()
      Return all base cells
    • h3ToLatLng

      public static LatLng h3ToLatLng(long h3)
      Find the LatLng center point of the cell.
    • h3ToLatLng

      public static LatLng h3ToLatLng(String h3Address)
      Find the LatLng center point of the cell.
    • h3ToGeoBoundary

      public static CellBoundary h3ToGeoBoundary(long h3)
      Find the cell CellBoundary coordinates for the cell
    • h3ToGeoBoundary

      public static CellBoundary h3ToGeoBoundary(String h3Address)
      Find the cell CellBoundary coordinates for the cell
    • geoToH3

      public static long geoToH3(double lat, double lng, int res)
      Find the H3 index of the resolution res cell containing the lat/lon (in degrees)
      Parameters:
      lat - Latitude in degrees.
      lng - Longitude in degrees.
      res - Resolution, 0 <= res <= 15
      Returns:
      The H3 index.
      Throws:
      IllegalArgumentException - latitude, longitude, or resolution are out of range.
    • geoToH3Address

      public static String geoToH3Address(double lat, double lng, int res)
      Find the H3 index of the resolution res cell containing the lat/lon (in degrees)
      Parameters:
      lat - Latitude in degrees.
      lng - Longitude in degrees.
      res - Resolution, 0 <= res <= 15
      Returns:
      The H3 index.
      Throws:
      IllegalArgumentException - Latitude, longitude, or resolution is out of range.
    • h3ToParent

      public static long h3ToParent(long h3)
      Returns the parent of the given index.
    • h3ToParent

      public static String h3ToParent(String h3Address)
      Returns the parent of the given index.
    • h3ToChildren

      public static long[] h3ToChildren(long h3)
      Returns the children of the given index.
    • h3ToChildren

      public static String[] h3ToChildren(String h3Address)
      Transforms a list of H3 indexes in long form to a list of H3 indexes in string form.
    • childPosToH3

      public static long childPosToH3(long h3, int childPos)
      Returns the child cell at the given position
    • childPosToH3

      public static String childPosToH3(String h3Address, int childPos)
      Returns the child address at the given position
    • h3ToNoChildrenIntersecting

      public static long[] h3ToNoChildrenIntersecting(long h3)
      Returns the h3 bins on the level below which are not children of the given H3 index but intersects with it.
    • h3ToNoChildrenIntersecting

      public static String[] h3ToNoChildrenIntersecting(String h3Address)
      Returns the h3 addresses on the level below which are not children of the given H3 address but intersects with it.
    • noChildIntersectingPosToH3

      public static long noChildIntersectingPosToH3(long h3, int childPos)
      Returns the no child intersecting cell at the given position
    • noChildIntersectingPosToH3

      public static String noChildIntersectingPosToH3(String h3Address, int childPos)
      Returns the no child intersecting cell at the given position
    • hexRing

      public static String[] hexRing(String h3Address)
      Returns the neighbor indexes.
      Parameters:
      h3Address - Origin index
      Returns:
      All neighbor indexes from the origin
    • hexRing

      public static long[] hexRing(long h3)
      Returns the neighbor indexes.
      Parameters:
      h3 - Origin index
      Returns:
      All neighbor indexes from the origin
    • hexRingSize

      public static int hexRingSize(long h3)
      Returns the number of neighbor indexes.
      Parameters:
      h3 - Origin index
      Returns:
      the number of neighbor indexes from the origin
    • hexRingSize

      public static int hexRingSize(String h3Address)
      Returns the number of neighbor indexes.
      Parameters:
      h3Address - Origin index
      Returns:
      the number of neighbor indexes from the origin
    • hexRingPosToH3

      public static long hexRingPosToH3(long h3, int ringPos)
      Returns the neighbor index at the given position.
      Parameters:
      h3 - Origin index
      ringPos - position of the neighbour index
      Returns:
      the actual neighbour at the given position
    • hexRingPosToH3

      public static String hexRingPosToH3(String h3Address, int ringPos)
      Returns the neighbor index at the given position.
      Parameters:
      h3Address - Origin index
      ringPos - position of the neighbour index
      Returns:
      the actual neighbour at the given position
    • areNeighborCells

      public static boolean areNeighborCells(String origin, String destination)
      returns whether or not the provided hexagons border
      Parameters:
      origin - the first index
      destination - the second index
      Returns:
      whether or not the provided hexagons border
    • areNeighborCells

      public static boolean areNeighborCells(long origin, long destination)
      returns whether or not the provided hexagons border
      Parameters:
      origin - the first index
      destination - the second index
      Returns:
      whether or not the provided hexagons border
    • h3ToChildrenSize

      public static long h3ToChildrenSize(long h3, int childRes)
      h3ToChildrenSize returns the exact number of children for a cell at a given child resolution.
      Parameters:
      h3 - H3Index to find the number of children of
      childRes - The child resolution you're interested in
      Returns:
      long Exact number of children (handles hexagons and pentagons correctly)
    • h3ToChildrenSize

      public static long h3ToChildrenSize(String h3Address, int childRes)
      h3ToChildrenSize returns the exact number of children for a h3 affress at a given child resolution.
      Parameters:
      h3Address - H3 address to find the number of children of
      childRes - The child resolution you're interested in
      Returns:
      int Exact number of children (handles hexagons and pentagons correctly)
    • h3ToChildrenSize

      public static int h3ToChildrenSize(long h3)
      h3ToChildrenSize returns the exact number of children
      Parameters:
      h3 - H3Index to find the number of children.
      Returns:
      int Exact number of children, 6 for Pentagons and 7 for hexagons,
    • h3ToChildrenSize

      public static int h3ToChildrenSize(String h3Address)
      h3ToChildrenSize returns the exact number of children
      Parameters:
      h3Address - H3 address to find the number of children.
      Returns:
      int Exact number of children, 6 for Pentagons and 7 for hexagons,
    • h3ToNotIntersectingChildrenSize

      public static int h3ToNotIntersectingChildrenSize(long h3)
      h3ToNotIntersectingChildrenSize returns the exact number of children intersecting the given parent but not part of the children set.
      Parameters:
      h3 - H3Index to find the number of children.
      Returns:
      int Exact number of children, 5 for Pentagons and 6 for hexagons,
    • h3ToNotIntersectingChildrenSize

      public static int h3ToNotIntersectingChildrenSize(String h3Address)
      h3ToNotIntersectingChildrenSize returns the exact number of children intersecting the given parent but not part of the children set.
      Parameters:
      h3Address - H3 address to find the number of children.
      Returns:
      int Exact number of children, 5 for Pentagons and 6 for hexagons,
    • northPolarH3

      public static long northPolarH3(int res)
      Find the h3 index containing the North Pole at the given resolution.
      Parameters:
      res - the provided resolution.
      Returns:
      the h3 index containing the North Pole.
    • northPolarH3Address

      public static String northPolarH3Address(int res)
      Find the h3 address containing the North Pole at the given resolution.
      Parameters:
      res - the provided resolution.
      Returns:
      the h3 address containing the North Pole.
    • southPolarH3

      public static long southPolarH3(int res)
      Find the h3 index containing the South Pole at the given resolution.
      Parameters:
      res - the provided resolution.
      Returns:
      the h3 index containing the South Pole.
    • southPolarH3Address

      public static String southPolarH3Address(int res)
      Find the h3 address containing the South Pole at the given resolution.
      Parameters:
      res - the provided resolution.
      Returns:
      the h3 address containing the South Pole.