Class H3Core

java.lang.Object
com.uber.h3core.H3Core

public class H3Core
extends java.lang.Object
H3Core provides all functions of the H3 API.

This class is thread safe and can be used as a singleton.

Any function in this class may throw H3Exception.

  • Method Summary

    Modifier and Type Method Description
    boolean areNeighborCells​(long a, long b)
    Returns true if the two indexes are neighbors.
    boolean areNeighborCells​(java.lang.String a, java.lang.String b)
    Returns true if the two indexes are neighbors.
    java.util.List<java.util.List<java.util.List<LatLng>>> cellAddressesToMultiPolygon​(java.util.Collection<java.lang.String> h3Addresses, boolean geoJson)
    Create polygons from a set of contiguous indexes
    double cellArea​(long h3, AreaUnit unit)
    Calculates the area of the given H3 cell.
    double cellArea​(java.lang.String h3Address, AreaUnit unit)
    Calculates the area of the given H3 cell.
    long cellsToDirectedEdge​(long a, long b)
    Returns a unidirectional edge index representing a towards b.
    java.lang.String cellsToDirectedEdge​(java.lang.String a, java.lang.String b)
    Returns a unidirectional edge index representing a towards b.
    java.util.List<java.util.List<java.util.List<LatLng>>> cellsToMultiPolygon​(java.util.Collection<java.lang.Long> h3, boolean geoJson)
    Create polygons from a set of contiguous indexes
    java.util.List<LatLng> cellToBoundary​(long h3)
    Find the cell boundary in latitude, longitude (degrees) coordinates for the cell
    java.util.List<LatLng> cellToBoundary​(java.lang.String h3Address)
    Find the cell boundary in latitude, longitude (degrees) coordinates for the cell
    long cellToCenterChild​(long h3, int childRes)
    Returns the center child at the given resolution.
    java.lang.String cellToCenterChild​(java.lang.String h3, int childRes)
    Returns the center child at the given resolution.
    long cellToChildPos​(long child, int parentRes)
    Returns the position of the child cell within an ordered list of all children of the cell's parent at the specified resolution parentRes.
    long cellToChildPos​(java.lang.String childAddress, int parentRes)
    Returns the position of the child cell within an ordered list of all children of the cell's parent at the specified resolution parentRes.
    java.util.List<java.lang.Long> cellToChildren​(long h3, int childRes)
    Provides the children of the index at the given resolution.
    java.util.List<java.lang.String> cellToChildren​(java.lang.String h3Address, int childRes)
    Provides the children of the index at the given resolution.
    long cellToChildrenSize​(long cell, int childRes)
    Returns the number of children the cell index has at the given resolution.
    long cellToChildrenSize​(java.lang.String cellAddress, int childRes)
    Returns the number of children the cell index has at the given resolution.
    LatLng cellToLatLng​(long h3)
    Find the latitude, longitude (both in degrees) center point of the cell.
    LatLng cellToLatLng​(java.lang.String h3Address)
    Find the latitude, longitude (degrees) center point of the cell.
    CoordIJ cellToLocalIj​(long origin, long h3)
    Converts h3 to IJ coordinates in a local coordinate space defined by origin .
    CoordIJ cellToLocalIj​(java.lang.String originAddress, java.lang.String h3Address)
    Converts h3Address to IJ coordinates in a local coordinate space defined by originAddress.
    long cellToParent​(long h3, int res)
    Returns the parent of the index at the given resolution.
    java.lang.String cellToParentAddress​(java.lang.String h3Address, int res)
    Returns the parent of the index at the given resolution.
    long cellToVertex​(long h3, int vertexNum)  
    java.lang.String cellToVertex​(java.lang.String h3Address, int vertexNum)  
    java.util.List<java.lang.Long> cellToVertexes​(long h3)  
    java.util.List<java.lang.String> cellToVertexes​(java.lang.String h3Address)  
    long childPosToCell​(long childPos, long parent, int childRes)
    Returns the child cell at a given position within an ordered list of all children of parent at the specified resolution childRes.
    java.lang.String childPosToCell​(long childPos, java.lang.String parentAddress, int childRes)
    Returns the child cell at a given position within an ordered list of all children of parent at the specified resolution childRes.
    java.util.List<java.lang.String> compactCellAddresses​(java.util.Collection<java.lang.String> h3Addresses)
    Returns a compacted set of indexes, at possibly coarser resolutions.
    java.util.List<java.lang.Long> compactCells​(java.util.Collection<java.lang.Long> h3)
    Returns a compacted set of indexes, at possibly coarser resolutions.
    java.util.List<LatLng> directedEdgeToBoundary​(long h3)
    Returns a list of coordinates representing the given edge.
    java.util.List<LatLng> directedEdgeToBoundary​(java.lang.String h3)
    Returns a list of coordinates representing the given edge.
    java.util.List<java.lang.Long> directedEdgeToCells​(long h3)
    Returns the origin and destination indexes (in that order) of the given unidirectional edge.
    java.util.List<java.lang.String> directedEdgeToCells​(java.lang.String h3)
    Returns the origin and destination indexes (in that order) of the given unidirectional edge.
    double edgeLength​(long edge, LengthUnit unit)
    Calculate the edge length of the given H3 edge.
    double edgeLength​(java.lang.String edgeAddress, LengthUnit unit)
    Calculate the edge length of the given H3 edge.
    int getBaseCellNumber​(long h3)
    Returns the base cell number for this index.
    int getBaseCellNumber​(java.lang.String h3Address)
    Returns the base cell number for this index.
    long getDirectedEdgeDestination​(long h3)
    Returns the destination index of the given unidirectional edge.
    java.lang.String getDirectedEdgeDestination​(java.lang.String h3)
    Returns the destination index of the given unidirectional edge.
    long getDirectedEdgeOrigin​(long h3)
    Returns the origin index of the given unidirectional edge.
    java.lang.String getDirectedEdgeOrigin​(java.lang.String h3)
    Returns the origin index of the given unidirectional edge.
    double getHexagonAreaAvg​(int res, AreaUnit unit)
    Returns the average area in unit for indexes at resolution res.
    double getHexagonEdgeLengthAvg​(int res, LengthUnit unit)
    Returns the average edge length in unit for indexes at resolution res .
    java.util.Collection<java.lang.Integer> getIcosahedronFaces​(long h3)
    Find all icosahedron faces intersected by a given H3 index, represented as integers from 0-19.
    java.util.Collection<java.lang.Integer> getIcosahedronFaces​(java.lang.String h3)
    Find all icosahedron faces intersected by a given H3 index, represented as integers from 0-19.
    long getNumCells​(int res)
    Returns the number of unique H3 indexes at resolution res.
    java.util.Collection<java.lang.String> getPentagonAddresses​(int res)
    Returns a collection of all topologically pentagonal cells at the given resolution.
    java.util.Collection<java.lang.Long> getPentagons​(int res)
    Returns a collection of all topologically pentagonal cells at the given resolution.
    java.util.Collection<java.lang.String> getRes0CellAddresses()
    Returns a collection of all base cells (H3 indexes are resolution 0).
    java.util.Collection<java.lang.Long> getRes0Cells()
    Returns a collection of all base cells (H3 indexes are resolution 0).
    int getResolution​(long h3)
    Returns the resolution of the provided index
    int getResolution​(java.lang.String h3Address)
    Returns the resolution of the provided index
    double greatCircleDistance​(LatLng a, LatLng b, LengthUnit unit)
    Return the distance along the sphere between two points.
    java.util.List<java.lang.Long> gridDisk​(long h3, int k)
    Neighboring indexes in all directions.
    java.util.List<java.lang.String> gridDisk​(java.lang.String h3Address, int k)
    Neighboring indexes in all directions.
    java.util.List<java.util.List<java.lang.Long>> gridDiskDistances​(long h3, int k)
    Neighboring indexes in all directions, ordered by distance from the origin index.
    java.util.List<java.util.List<java.lang.String>> gridDiskDistances​(java.lang.String h3Address, int k)
    Neighboring indexes in all directions, ordered by distance from the origin index.
    java.util.List<java.util.List<java.lang.Long>> gridDiskUnsafe​(long h3, int k)
    Returns in order neighbor traversal.
    java.util.List<java.util.List<java.lang.String>> gridDiskUnsafe​(java.lang.String h3Address, int k)
    Returns in order neighbor traversal.
    long gridDistance​(long a, long b)
    Returns the distance between a and b.
    long gridDistance​(java.lang.String a, java.lang.String b)
    Returns the distance between a and b.
    java.util.List<java.lang.Long> gridPathCells​(long start, long end)
    Given two H3 indexes, return the line of indexes between them (inclusive of endpoints).
    java.util.List<java.lang.String> gridPathCells​(java.lang.String startAddress, java.lang.String endAddress)
    Given two H3 indexes, return the line of indexes between them (inclusive of endpoints).
    java.util.List<java.lang.Long> gridRing​(long h3, int k)
    Returns in order neighbor traversal, of indexes with distance of k.
    java.util.List<java.lang.String> gridRing​(java.lang.String h3Address, int k)
    Returns in order neighbor traversal, of indexes with distance of k.
    java.util.List<java.lang.Long> gridRingUnsafe​(long h3, int k)
    Returns in order neighbor traversal, of indexes with distance of k.
    java.util.List<java.lang.String> gridRingUnsafe​(java.lang.String h3Address, int k)
    Returns in order neighbor traversal, of indexes with distance of k.
    java.lang.String h3ToString​(long h3)
    Converts from long representation of an index to String representation.
    boolean isPentagon​(long h3)
    Returns true if this index is one of twelve pentagons per resolution.
    boolean isPentagon​(java.lang.String h3Address)
    Returns true if this index is one of twelve pentagons per resolution.
    boolean isResClassIII​(long h3)
    Determines if an index is Class III or Class II.
    boolean isResClassIII​(java.lang.String h3Address)
    Determines if an index is Class III or Class II.
    boolean isValidCell​(long h3)
    Returns true if this is a valid H3 index.
    boolean isValidCell​(java.lang.String h3Address)
    Returns true if this is a valid H3 index.
    boolean isValidDirectedEdge​(long h3)
    Returns true if the given index is a valid unidirectional edge.
    boolean isValidDirectedEdge​(java.lang.String h3)
    Returns true if the given index is a valid unidirectional edge.
    boolean isValidVertex​(long h3)  
    boolean isValidVertex​(java.lang.String h3Address)  
    long latLngToCell​(double lat, double lng, int res)
    Find the H3 index of the resolution res cell containing the lat/lon (in degrees)
    java.lang.String latLngToCellAddress​(double lat, double lng, int res)
    Find the H3 index of the resolution res cell containing the lat/lon (in degrees)
    long localIjToCell​(long origin, CoordIJ ij)
    Converts the IJ coordinates to an index, using a local IJ coordinate space anchored by origin.
    java.lang.String localIjToCell​(java.lang.String originAddress, CoordIJ ij)
    Converts the IJ coordinates to an index, using a local IJ coordinate space anchored by origin.
    static H3Core newInstance()
    Create by unpacking the H3 native library to disk and loading it.
    static H3Core newInstance​(H3CoreLoader.OperatingSystem os, java.lang.String arch)
    Create by unpacking the H3 native library to disk and loading it.
    static H3Core newSystemInstance()
    Create by using the H3 native library already installed on the system.
    java.util.List<java.lang.Long> originToDirectedEdges​(long h3)
    Returns all unidirectional edges originating from the given index.
    java.util.List<java.lang.String> originToDirectedEdges​(java.lang.String h3)
    Returns all unidirectional edges originating from the given index.
    java.util.List<java.lang.String> polygonToCellAddresses​(java.util.List<LatLng> points, java.util.List<java.util.List<LatLng>> holes, int res)
    Finds indexes within the given geopolygon.
    java.util.List<java.lang.String> polygonToCellAddressesExperimental​(java.util.List<LatLng> points, java.util.List<java.util.List<LatLng>> holes, int res, PolygonToCellsFlags flags)
    Finds indexes within the given geopolygon.
    java.util.List<java.lang.Long> polygonToCells​(java.util.List<LatLng> points, java.util.List<java.util.List<LatLng>> holes, int res)
    Finds indexes within the given geopolygon.
    java.util.List<java.lang.Long> polygonToCellsExperimental​(java.util.List<LatLng> points, java.util.List<java.util.List<LatLng>> holes, int res, PolygonToCellsFlags flags)
    Finds indexes within the given geopolygon.
    long stringToH3​(java.lang.String h3Address)
    Converts from String representation of an index to long representation.
    java.util.List<java.lang.String> uncompactCellAddresses​(java.util.Collection<java.lang.String> h3Addresses, int res)
    Uncompacts all the given indexes to resolution res.
    java.util.List<java.lang.Long> uncompactCells​(java.util.Collection<java.lang.Long> h3, int res)
    Uncompacts all the given indexes to resolution res.
    LatLng vertexToLatLng​(long h3)  
    LatLng vertexToLatLng​(java.lang.String h3Address)  

    Methods inherited from class java.lang.Object

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

    • newInstance

      public static H3Core newInstance() throws java.io.IOException
      Create by unpacking the H3 native library to disk and loading it. The library will attempt to detect the correct operating system and architecture of native library to unpack.
      Throws:
      java.lang.SecurityException - Loading the library was not allowed by the SecurityManager.
      java.lang.UnsatisfiedLinkError - The library could not be loaded
      java.io.IOException - The library could not be extracted to disk.
    • newInstance

      public static H3Core newInstance​(H3CoreLoader.OperatingSystem os, java.lang.String arch) throws java.io.IOException
      Create by unpacking the H3 native library to disk and loading it. The library will attempt to extract the native library matching the given arguments to disk.
      Throws:
      java.lang.SecurityException - Loading the library was not allowed by the SecurityManager.
      java.lang.UnsatisfiedLinkError - The library could not be loaded
      java.io.IOException - The library could not be extracted to disk.
    • newSystemInstance

      public static H3Core newSystemInstance()
      Create by using the H3 native library already installed on the system.
      Throws:
      java.lang.SecurityException - The library could not be loaded
      java.lang.UnsatisfiedLinkError - The library could not be loaded
    • isValidCell

      public boolean isValidCell​(long h3)
      Returns true if this is a valid H3 index.
    • isValidCell

      public boolean isValidCell​(java.lang.String h3Address)
      Returns true if this is a valid H3 index.
    • getBaseCellNumber

      public int getBaseCellNumber​(long h3)
      Returns the base cell number for this index.
    • getBaseCellNumber

      public int getBaseCellNumber​(java.lang.String h3Address)
      Returns the base cell number for this index.
    • isPentagon

      public boolean isPentagon​(long h3)
      Returns true if this index is one of twelve pentagons per resolution.
    • isPentagon

      public boolean isPentagon​(java.lang.String h3Address)
      Returns true if this index is one of twelve pentagons per resolution.
    • latLngToCell

      public long latLngToCell​(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.
    • latLngToCellAddress

      public java.lang.String latLngToCellAddress​(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.
    • cellToLatLng

      public LatLng cellToLatLng​(long h3)
      Find the latitude, longitude (both in degrees) center point of the cell.
    • cellToLatLng

      public LatLng cellToLatLng​(java.lang.String h3Address)
      Find the latitude, longitude (degrees) center point of the cell.
    • cellToBoundary

      public java.util.List<LatLng> cellToBoundary​(long h3)
      Find the cell boundary in latitude, longitude (degrees) coordinates for the cell
    • cellToBoundary

      public java.util.List<LatLng> cellToBoundary​(java.lang.String h3Address)
      Find the cell boundary in latitude, longitude (degrees) coordinates for the cell
    • gridDisk

      public java.util.List<java.lang.String> gridDisk​(java.lang.String h3Address, int k)
      Neighboring indexes in all directions.
      Parameters:
      h3Address - Origin index
      k - Number of rings around the origin
    • gridDisk

      public java.util.List<java.lang.Long> gridDisk​(long h3, int k)
      Neighboring indexes in all directions.
      Parameters:
      h3 - Origin index
      k - Number of rings around the origin
    • gridDiskDistances

      public java.util.List<java.util.List<java.lang.String>> gridDiskDistances​(java.lang.String h3Address, int k)
      Neighboring indexes in all directions, ordered by distance from the origin index.
      Parameters:
      h3Address - Origin index
      k - Number of rings around the origin
      Returns:
      A list of rings, each of which is a list of addresses. The rings are in order from closest to origin to farthest.
    • gridDiskDistances

      public java.util.List<java.util.List<java.lang.Long>> gridDiskDistances​(long h3, int k)
      Neighboring indexes in all directions, ordered by distance from the origin index.
      Parameters:
      h3 - Origin index
      k - Number of rings around the origin
      Returns:
      A list of rings, each of which is a list of addresses. The rings are in order from closest to origin to farthest.
    • gridDiskUnsafe

      public java.util.List<java.util.List<java.lang.String>> gridDiskUnsafe​(java.lang.String h3Address, int k)
      Returns in order neighbor traversal.
      Parameters:
      h3Address - Origin hexagon index
      k - Number of rings around the origin
      Returns:
      A list of rings, each of which is a list of addresses. The rings are in order from closest to origin to farthest.
    • gridDiskUnsafe

      public java.util.List<java.util.List<java.lang.Long>> gridDiskUnsafe​(long h3, int k)
      Returns in order neighbor traversal.
      Parameters:
      h3 - Origin hexagon index
      k - Number of rings around the origin
      Returns:
      A list of rings, each of which is a list of addresses. The rings are in order from closest to origin to farthest.
    • gridRing

      public java.util.List<java.lang.String> gridRing​(java.lang.String h3Address, int k)
      Returns in order neighbor traversal, of indexes with distance of k.
      Parameters:
      h3Address - Origin index
      k - Number of rings around the origin
      Returns:
      All indexes k away from the origin
    • gridRing

      public java.util.List<java.lang.Long> gridRing​(long h3, int k)
      Returns in order neighbor traversal, of indexes with distance of k.
      Parameters:
      h3 - Origin index
      k - Number of rings around the origin
      Returns:
      All indexes k away from the origin
    • gridRingUnsafe

      public java.util.List<java.lang.String> gridRingUnsafe​(java.lang.String h3Address, int k)
      Returns in order neighbor traversal, of indexes with distance of k.
      Parameters:
      h3Address - Origin index
      k - Number of rings around the origin
      Returns:
      All indexes k away from the origin
    • gridRingUnsafe

      public java.util.List<java.lang.Long> gridRingUnsafe​(long h3, int k)
      Returns in order neighbor traversal, of indexes with distance of k.
      Parameters:
      h3 - Origin index
      k - Number of rings around the origin
      Returns:
      All indexes k away from the origin
    • gridDistance

      public long gridDistance​(java.lang.String a, java.lang.String b)
      Returns the distance between a and b. This is the grid distance, or distance expressed in number of H3 cells.

      In some cases H3 cannot compute the distance between two indexes. This can happen because:

      • The indexes are not comparable (difference resolutions, etc)
      • The distance is greater than the H3 core library supports
      • The H3 library does not support finding the distance between the two cells, because of pentagonal distortion.
      Parameters:
      a - An H3 index
      b - Another H3 index
      Returns:
      Distance between the two in grid cells
    • gridDistance

      public long gridDistance​(long a, long b)
      Returns the distance between a and b. This is the grid distance, or distance expressed in number of H3 cells.

      In some cases H3 cannot compute the distance between two indexes. This can happen because:

      • The indexes are not comparable (difference resolutions, etc)
      • The distance is greater than the H3 core library supports
      • The H3 library does not support finding the distance between the two cells, because of pentagonal distortion.
      Parameters:
      a - An H3 index
      b - Another H3 index
      Returns:
      Distance between the two in grid cells
    • cellToLocalIj

      public CoordIJ cellToLocalIj​(long origin, long h3)
      Converts h3 to IJ coordinates in a local coordinate space defined by origin .

      The local IJ coordinate space may have deleted regions and warping due to pentagon distortion. IJ coordinates are only comparable if they came from the same origin.

      This function is experimental, and its output is not guaranteed to be compatible across different versions of H3.

      Parameters:
      origin - Anchoring index for the local coordinate space.
      h3 - Index to find the coordinates of.
      Returns:
      Coordinates for h3 in the local coordinate space.
    • cellToLocalIj

      public CoordIJ cellToLocalIj​(java.lang.String originAddress, java.lang.String h3Address)
      Converts h3Address to IJ coordinates in a local coordinate space defined by originAddress.

      The local IJ coordinate space may have deleted regions and warping due to pentagon distortion. IJ coordinates are only comparable if they came from the same origin.

      This function is experimental, and its output is not guaranteed to be compatible across different versions of H3.

      Parameters:
      originAddress - Anchoring index for the local coordinate space.
      h3Address - Index to find the coordinates of.
      Returns:
      Coordinates for h3 in the local coordinate space.
    • localIjToCell

      public long localIjToCell​(long origin, CoordIJ ij)
      Converts the IJ coordinates to an index, using a local IJ coordinate space anchored by origin.

      The local IJ coordinate space may have deleted regions and warping due to pentagon distortion. IJ coordinates are only comparable if they came from the same origin.

      This function is experimental, and its output is not guaranteed to be compatible across different versions of H3.

      Parameters:
      origin - Anchoring index for the local coordinate space.
      ij - Coordinates in the local IJ coordinate space.
      Returns:
      Index represented by ij
    • localIjToCell

      public java.lang.String localIjToCell​(java.lang.String originAddress, CoordIJ ij)
      Converts the IJ coordinates to an index, using a local IJ coordinate space anchored by origin.

      The local IJ coordinate space may have deleted regions and warping due to pentagon distortion. IJ coordinates are only comparable if they came from the same origin.

      This function is experimental, and its output is not guaranteed to be compatible across different versions of H3.

      Parameters:
      originAddress - Anchoring index for the local coordinate space.
      ij - Coordinates in the local IJ coordinate space.
      Returns:
      Index represented by ij
    • gridPathCells

      public java.util.List<java.lang.String> gridPathCells​(java.lang.String startAddress, java.lang.String endAddress)
      Given two H3 indexes, return the line of indexes between them (inclusive of endpoints).

      This function may fail to find the line between two indexes, for example if they are very far apart. It may also fail when finding distances for indexes on opposite sides of a pentagon.

      Notes:

      • The specific output of this function should not be considered stable across library versions. The only guarantees the library provides are that the line length will be `h3Distance(start, end) + 1` and that every index in the line will be a neighbor of the preceding index.
      • Lines are drawn in grid space, and may not correspond exactly to either Cartesian lines or great arcs.
      Parameters:
      startAddress - Start index of the line
      endAddress - End index of the line
      Returns:
      Indexes making up the line.
    • gridPathCells

      public java.util.List<java.lang.Long> gridPathCells​(long start, long end)
      Given two H3 indexes, return the line of indexes between them (inclusive of endpoints).

      This function may fail to find the line between two indexes, for example if they are very far apart. It may also fail when finding distances for indexes on opposite sides of a pentagon.

      Notes:

      • The specific output of this function should not be considered stable across library versions. The only guarantees the library provides are that the line length will be `h3Distance(start, end) + 1` and that every index in the line will be a neighbor of the preceding index.
      • Lines are drawn in grid space, and may not correspond exactly to either Cartesian lines or great arcs.
      Parameters:
      start - Start index of the line
      end - End index of the line
      Returns:
      Indexes making up the line.
    • polygonToCellAddressesExperimental

      public java.util.List<java.lang.String> polygonToCellAddressesExperimental​(java.util.List<LatLng> points, java.util.List<java.util.List<LatLng>> holes, int res, PolygonToCellsFlags flags)
      Finds indexes within the given geopolygon.
      Parameters:
      points - Outline geopolygon
      holes - Geopolygons of any internal holes
      res - Resolution of the desired indexes
    • polygonToCellsExperimental

      public java.util.List<java.lang.Long> polygonToCellsExperimental​(java.util.List<LatLng> points, java.util.List<java.util.List<LatLng>> holes, int res, PolygonToCellsFlags flags)
      Finds indexes within the given geopolygon.
      Parameters:
      points - Outline geopolygon
      holes - Geopolygon of any internal holes
      res - Resolution of the desired indexes
      Throws:
      java.lang.IllegalArgumentException - Invalid resolution
    • polygonToCellAddresses

      public java.util.List<java.lang.String> polygonToCellAddresses​(java.util.List<LatLng> points, java.util.List<java.util.List<LatLng>> holes, int res)
      Finds indexes within the given geopolygon.
      Parameters:
      points - Outline geopolygon
      holes - Geopolygons of any internal holes
      res - Resolution of the desired indexes
    • polygonToCells

      public java.util.List<java.lang.Long> polygonToCells​(java.util.List<LatLng> points, java.util.List<java.util.List<LatLng>> holes, int res)
      Finds indexes within the given geopolygon.
      Parameters:
      points - Outline geopolygon
      holes - Geopolygon of any internal holes
      res - Resolution of the desired indexes
      Throws:
      java.lang.IllegalArgumentException - Invalid resolution
    • cellAddressesToMultiPolygon

      public java.util.List<java.util.List<java.util.List<LatLng>>> cellAddressesToMultiPolygon​(java.util.Collection<java.lang.String> h3Addresses, boolean geoJson)
      Create polygons from a set of contiguous indexes
    • cellsToMultiPolygon

      public java.util.List<java.util.List<java.util.List<LatLng>>> cellsToMultiPolygon​(java.util.Collection<java.lang.Long> h3, boolean geoJson)
      Create polygons from a set of contiguous indexes
    • getResolution

      public int getResolution​(java.lang.String h3Address)
      Returns the resolution of the provided index
    • getResolution

      public int getResolution​(long h3)
      Returns the resolution of the provided index
    • cellToParent

      public long cellToParent​(long h3, int res)
      Returns the parent of the index at the given resolution.
      Parameters:
      h3 - H3 index.
      res - Resolution of the parent, 0 <= res <= h3GetResolution(h3)
      Throws:
      java.lang.IllegalArgumentException - res is not between 0 and the resolution of h3, inclusive.
    • cellToParentAddress

      public java.lang.String cellToParentAddress​(java.lang.String h3Address, int res)
      Returns the parent of the index at the given resolution.
      Parameters:
      h3Address - H3 index.
      res - Resolution of the parent, 0 <= res <= h3GetResolution(h3)
    • cellToChildren

      public java.util.List<java.lang.String> cellToChildren​(java.lang.String h3Address, int childRes)
      Provides the children of the index at the given resolution.
      Parameters:
      childRes - Resolution of the children
    • cellToChildren

      public java.util.List<java.lang.Long> cellToChildren​(long h3, int childRes)
      Provides the children of the index at the given resolution.
      Parameters:
      h3 - H3 index.
      childRes - Resolution of the children
      Throws:
      java.lang.IllegalArgumentException - Invalid resolution
    • cellToCenterChild

      public java.lang.String cellToCenterChild​(java.lang.String h3, int childRes)
      Returns the center child at the given resolution.
      Parameters:
      h3 - Parent H3 index
      childRes - Resolution of the child
      Throws:
      java.lang.IllegalArgumentException - Invalid resolution (e.g. coarser than the parent)
    • cellToChildrenSize

      public long cellToChildrenSize​(long cell, int childRes)
      Returns the number of children the cell index has at the given resolution.
    • cellToChildrenSize

      public long cellToChildrenSize​(java.lang.String cellAddress, int childRes)
      Returns the number of children the cell index has at the given resolution.
    • cellToCenterChild

      public long cellToCenterChild​(long h3, int childRes)
      Returns the center child at the given resolution.
      Parameters:
      h3 - Parent H3 index
      childRes - Resolution of the child
      Throws:
      java.lang.IllegalArgumentException - Invalid resolution (e.g. coarser than the parent)
    • isResClassIII

      public boolean isResClassIII​(java.lang.String h3Address)
      Determines if an index is Class III or Class II.
      Returns:
      true if the index is Class III
    • isResClassIII

      public boolean isResClassIII​(long h3)
      Determines if an index is Class III or Class II.
      Parameters:
      h3 - H3 index.
      Returns:
      true if the index is Class III
    • compactCellAddresses

      public java.util.List<java.lang.String> compactCellAddresses​(java.util.Collection<java.lang.String> h3Addresses)
      Returns a compacted set of indexes, at possibly coarser resolutions.
    • compactCells

      public java.util.List<java.lang.Long> compactCells​(java.util.Collection<java.lang.Long> h3)
      Returns a compacted set of indexes, at possibly coarser resolutions.
    • uncompactCellAddresses

      public java.util.List<java.lang.String> uncompactCellAddresses​(java.util.Collection<java.lang.String> h3Addresses, int res)
      Uncompacts all the given indexes to resolution res.
    • uncompactCells

      public java.util.List<java.lang.Long> uncompactCells​(java.util.Collection<java.lang.Long> h3, int res)
      Uncompacts all the given indexes to resolution res.
    • h3ToString

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

      public long stringToH3​(java.lang.String h3Address)
      Converts from String representation of an index to long representation.
    • cellArea

      public double cellArea​(java.lang.String h3Address, AreaUnit unit)
      Calculates the area of the given H3 cell.
      Parameters:
      h3Address - Cell to find the area of.
      unit - Unit to calculate the area in.
      Returns:
      Cell area in the given units.
    • cellArea

      public double cellArea​(long h3, AreaUnit unit)
      Calculates the area of the given H3 cell.
      Parameters:
      h3 - Cell to find the area of.
      unit - Unit to calculate the area in.
      Returns:
      Cell area in the given units.
    • greatCircleDistance

      public double greatCircleDistance​(LatLng a, LatLng b, LengthUnit unit)
      Return the distance along the sphere between two points.
      Parameters:
      a - First point
      b - Second point
      unit - Unit to return the distance in.
      Returns:
      Distance from point a to point b
    • edgeLength

      public double edgeLength​(java.lang.String edgeAddress, LengthUnit unit)
      Calculate the edge length of the given H3 edge.
      Parameters:
      edgeAddress - Edge to find the edge length of.
      unit - Unit of measure to use.
      Returns:
      Length of the given edge.
    • edgeLength

      public double edgeLength​(long edge, LengthUnit unit)
      Calculate the edge length of the given H3 edge.
      Parameters:
      edge - Edge to find the edge length of.
      unit - Unit of measure to use.
      Returns:
      Length of the given edge.
    • getHexagonAreaAvg

      public double getHexagonAreaAvg​(int res, AreaUnit unit)
      Returns the average area in unit for indexes at resolution res.
      Throws:
      java.lang.IllegalArgumentException - Invalid parameter value
    • getHexagonEdgeLengthAvg

      public double getHexagonEdgeLengthAvg​(int res, LengthUnit unit)
      Returns the average edge length in unit for indexes at resolution res .
      Throws:
      java.lang.IllegalArgumentException - Invalid parameter value
    • getNumCells

      public long getNumCells​(int res)
      Returns the number of unique H3 indexes at resolution res.
      Throws:
      java.lang.IllegalArgumentException - Invalid resolution
    • getRes0CellAddresses

      public java.util.Collection<java.lang.String> getRes0CellAddresses()
      Returns a collection of all base cells (H3 indexes are resolution 0).
    • getRes0Cells

      public java.util.Collection<java.lang.Long> getRes0Cells()
      Returns a collection of all base cells (H3 indexes are resolution 0).
    • getPentagonAddresses

      public java.util.Collection<java.lang.String> getPentagonAddresses​(int res)
      Returns a collection of all topologically pentagonal cells at the given resolution.
      Throws:
      java.lang.IllegalArgumentException - Invalid resolution.
    • getPentagons

      public java.util.Collection<java.lang.Long> getPentagons​(int res)
      Returns a collection of all topologically pentagonal cells at the given resolution.
      Throws:
      java.lang.IllegalArgumentException - Invalid resolution.
    • areNeighborCells

      public boolean areNeighborCells​(long a, long b)
      Returns true if the two indexes are neighbors.
    • areNeighborCells

      public boolean areNeighborCells​(java.lang.String a, java.lang.String b)
      Returns true if the two indexes are neighbors.
    • cellsToDirectedEdge

      public long cellsToDirectedEdge​(long a, long b)
      Returns a unidirectional edge index representing a towards b.
      Throws:
      java.lang.IllegalArgumentException - The indexes are not neighbors.
    • cellsToDirectedEdge

      public java.lang.String cellsToDirectedEdge​(java.lang.String a, java.lang.String b)
      Returns a unidirectional edge index representing a towards b.
      Throws:
      java.lang.IllegalArgumentException - The indexes are not neighbors.
    • isValidDirectedEdge

      public boolean isValidDirectedEdge​(long h3)
      Returns true if the given index is a valid unidirectional edge.
    • isValidDirectedEdge

      public boolean isValidDirectedEdge​(java.lang.String h3)
      Returns true if the given index is a valid unidirectional edge.
    • getDirectedEdgeOrigin

      public long getDirectedEdgeOrigin​(long h3)
      Returns the origin index of the given unidirectional edge.
    • getDirectedEdgeOrigin

      public java.lang.String getDirectedEdgeOrigin​(java.lang.String h3)
      Returns the origin index of the given unidirectional edge.
    • getDirectedEdgeDestination

      public long getDirectedEdgeDestination​(long h3)
      Returns the destination index of the given unidirectional edge.
    • getDirectedEdgeDestination

      public java.lang.String getDirectedEdgeDestination​(java.lang.String h3)
      Returns the destination index of the given unidirectional edge.
    • directedEdgeToCells

      public java.util.List<java.lang.Long> directedEdgeToCells​(long h3)
      Returns the origin and destination indexes (in that order) of the given unidirectional edge.
    • directedEdgeToCells

      public java.util.List<java.lang.String> directedEdgeToCells​(java.lang.String h3)
      Returns the origin and destination indexes (in that order) of the given unidirectional edge.
    • originToDirectedEdges

      public java.util.List<java.lang.Long> originToDirectedEdges​(long h3)
      Returns all unidirectional edges originating from the given index.
    • originToDirectedEdges

      public java.util.List<java.lang.String> originToDirectedEdges​(java.lang.String h3)
      Returns all unidirectional edges originating from the given index.
    • directedEdgeToBoundary

      public java.util.List<LatLng> directedEdgeToBoundary​(long h3)
      Returns a list of coordinates representing the given edge.
    • directedEdgeToBoundary

      public java.util.List<LatLng> directedEdgeToBoundary​(java.lang.String h3)
      Returns a list of coordinates representing the given edge.
    • getIcosahedronFaces

      public java.util.Collection<java.lang.Integer> getIcosahedronFaces​(java.lang.String h3)
      Find all icosahedron faces intersected by a given H3 index, represented as integers from 0-19.
      Parameters:
      h3 - Index to find icosahedron faces for.
      Returns:
      A collection of faces intersected by the index.
    • getIcosahedronFaces

      public java.util.Collection<java.lang.Integer> getIcosahedronFaces​(long h3)
      Find all icosahedron faces intersected by a given H3 index, represented as integers from 0-19.
      Parameters:
      h3 - Index to find icosahedron faces for.
      Returns:
      A collection of faces intersected by the index.
    • cellToVertex

      public long cellToVertex​(long h3, int vertexNum)
    • cellToVertex

      public java.lang.String cellToVertex​(java.lang.String h3Address, int vertexNum)
    • cellToVertexes

      public java.util.List<java.lang.Long> cellToVertexes​(long h3)
    • cellToVertexes

      public java.util.List<java.lang.String> cellToVertexes​(java.lang.String h3Address)
    • vertexToLatLng

      public LatLng vertexToLatLng​(long h3)
    • vertexToLatLng

      public LatLng vertexToLatLng​(java.lang.String h3Address)
    • isValidVertex

      public boolean isValidVertex​(long h3)
    • isValidVertex

      public boolean isValidVertex​(java.lang.String h3Address)
    • cellToChildPos

      public long cellToChildPos​(java.lang.String childAddress, int parentRes)
      Returns the position of the child cell within an ordered list of all children of the cell's parent at the specified resolution parentRes.
    • cellToChildPos

      public long cellToChildPos​(long child, int parentRes)
      Returns the position of the child cell within an ordered list of all children of the cell's parent at the specified resolution parentRes.
    • childPosToCell

      public long childPosToCell​(long childPos, long parent, int childRes)
      Returns the child cell at a given position within an ordered list of all children of parent at the specified resolution childRes.
    • childPosToCell

      public java.lang.String childPosToCell​(long childPos, java.lang.String parentAddress, int childRes)
      Returns the child cell at a given position within an ordered list of all children of parent at the specified resolution childRes.