Class H3Core
public class H3Core
extends java.lang.Object
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 booleanareNeighborCells(long a, long b)Returnstrueif the two indexes are neighbors.booleanareNeighborCells(java.lang.String a, java.lang.String b)Returnstrueif 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 indexesdoublecellArea(long h3, AreaUnit unit)Calculates the area of the given H3 cell.doublecellArea(java.lang.String h3Address, AreaUnit unit)Calculates the area of the given H3 cell.longcellsToDirectedEdge(long a, long b)Returns a unidirectional edge index representingatowardsb.java.lang.StringcellsToDirectedEdge(java.lang.String a, java.lang.String b)Returns a unidirectional edge index representingatowardsb.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 indexesjava.util.List<LatLng>cellToBoundary(long h3)Find the cell boundary in latitude, longitude (degrees) coordinates for the celljava.util.List<LatLng>cellToBoundary(java.lang.String h3Address)Find the cell boundary in latitude, longitude (degrees) coordinates for the celllongcellToCenterChild(long h3, int childRes)Returns the center child at the given resolution.java.lang.StringcellToCenterChild(java.lang.String h3, int childRes)Returns the center child at the given resolution.longcellToChildPos(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.longcellToChildPos(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.longcellToChildrenSize(long cell, int childRes)Returns the number of children the cell index has at the given resolution.longcellToChildrenSize(java.lang.String cellAddress, int childRes)Returns the number of children the cell index has at the given resolution.LatLngcellToLatLng(long h3)Find the latitude, longitude (both in degrees) center point of the cell.LatLngcellToLatLng(java.lang.String h3Address)Find the latitude, longitude (degrees) center point of the cell.CoordIJcellToLocalIj(long origin, long h3)Convertsh3to IJ coordinates in a local coordinate space defined byorigin.CoordIJcellToLocalIj(java.lang.String originAddress, java.lang.String h3Address)Convertsh3Addressto IJ coordinates in a local coordinate space defined byoriginAddress.longcellToParent(long h3, int res)Returns the parent of the index at the given resolution.java.lang.StringcellToParentAddress(java.lang.String h3Address, int res)Returns the parent of the index at the given resolution.longcellToVertex(long h3, int vertexNum)java.lang.StringcellToVertex(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)longchildPosToCell(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.StringchildPosToCell(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.doubleedgeLength(long edge, LengthUnit unit)Calculate the edge length of the given H3 edge.doubleedgeLength(java.lang.String edgeAddress, LengthUnit unit)Calculate the edge length of the given H3 edge.intgetBaseCellNumber(long h3)Returns the base cell number for this index.intgetBaseCellNumber(java.lang.String h3Address)Returns the base cell number for this index.longgetDirectedEdgeDestination(long h3)Returns the destination index of the given unidirectional edge.java.lang.StringgetDirectedEdgeDestination(java.lang.String h3)Returns the destination index of the given unidirectional edge.longgetDirectedEdgeOrigin(long h3)Returns the origin index of the given unidirectional edge.java.lang.StringgetDirectedEdgeOrigin(java.lang.String h3)Returns the origin index of the given unidirectional edge.doublegetHexagonAreaAvg(int res, AreaUnit unit)Returns the average area inunitfor indexes at resolutionres.doublegetHexagonEdgeLengthAvg(int res, LengthUnit unit)Returns the average edge length inunitfor indexes at resolutionres.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.longgetNumCells(int res)Returns the number of unique H3 indexes at resolutionres.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).intgetResolution(long h3)Returns the resolution of the provided indexintgetResolution(java.lang.String h3Address)Returns the resolution of the provided indexdoublegreatCircleDistance(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.longgridDistance(long a, long b)Returns the distance betweenaandb.longgridDistance(java.lang.String a, java.lang.String b)Returns the distance betweenaandb.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 ofk.java.util.List<java.lang.String>gridRing(java.lang.String h3Address, int k)Returns in order neighbor traversal, of indexes with distance ofk.java.util.List<java.lang.Long>gridRingUnsafe(long h3, int k)Returns in order neighbor traversal, of indexes with distance ofk.java.util.List<java.lang.String>gridRingUnsafe(java.lang.String h3Address, int k)Returns in order neighbor traversal, of indexes with distance ofk.java.lang.Stringh3ToString(long h3)Converts fromlongrepresentation of an index toStringrepresentation.booleanisPentagon(long h3)Returnstrueif this index is one of twelve pentagons per resolution.booleanisPentagon(java.lang.String h3Address)Returnstrueif this index is one of twelve pentagons per resolution.booleanisResClassIII(long h3)Determines if an index is Class III or Class II.booleanisResClassIII(java.lang.String h3Address)Determines if an index is Class III or Class II.booleanisValidCell(long h3)Returns true if this is a valid H3 index.booleanisValidCell(java.lang.String h3Address)Returns true if this is a valid H3 index.booleanisValidDirectedEdge(long h3)Returnstrueif the given index is a valid unidirectional edge.booleanisValidDirectedEdge(java.lang.String h3)Returnstrueif the given index is a valid unidirectional edge.booleanisValidVertex(long h3)booleanisValidVertex(java.lang.String h3Address)longlatLngToCell(double lat, double lng, int res)Find the H3 index of the resolutionrescell containing the lat/lon (in degrees)java.lang.StringlatLngToCellAddress(double lat, double lng, int res)Find the H3 index of the resolutionrescell containing the lat/lon (in degrees)longlocalIjToCell(long origin, CoordIJ ij)Converts the IJ coordinates to an index, using a local IJ coordinate space anchored byorigin.java.lang.StringlocalIjToCell(java.lang.String originAddress, CoordIJ ij)Converts the IJ coordinates to an index, using a local IJ coordinate space anchored byorigin.static H3CorenewInstance()Create by unpacking the H3 native library to disk and loading it.static H3CorenewInstance(H3CoreLoader.OperatingSystem os, java.lang.String arch)Create by unpacking the H3 native library to disk and loading it.static H3CorenewSystemInstance()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.longstringToH3(java.lang.String h3Address)Converts fromStringrepresentation of an index tolongrepresentation.java.util.List<java.lang.String>uncompactCellAddresses(java.util.Collection<java.lang.String> h3Addresses, int res)Uncompacts all the given indexes to resolutionres.java.util.List<java.lang.Long>uncompactCells(java.util.Collection<java.lang.Long> h3, int res)Uncompacts all the given indexes to resolutionres.LatLngvertexToLatLng(long h3)LatLngvertexToLatLng(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
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 loadedjava.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.IOExceptionCreate 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 loadedjava.io.IOException- The library could not be extracted to disk.
-
newSystemInstance
Create by using the H3 native library already installed on the system.- Throws:
java.lang.SecurityException- The library could not be loadedjava.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)Returnstrueif this index is one of twelve pentagons per resolution. -
isPentagon
public boolean isPentagon(java.lang.String h3Address)Returnstrueif 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 resolutionrescell 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 resolutionrescell 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
Find the latitude, longitude (both in degrees) center point of the cell. -
cellToLatLng
Find the latitude, longitude (degrees) center point of the cell. -
cellToBoundary
Find the cell boundary in latitude, longitude (degrees) coordinates for the cell -
cellToBoundary
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 indexk- 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 indexk- 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 indexk- 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 indexk- 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 indexk- 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 indexk- 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 ofk.- Parameters:
h3Address- Origin indexk- Number of rings around the origin- Returns:
- All indexes
kaway 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 ofk.- Parameters:
h3- Origin indexk- Number of rings around the origin- Returns:
- All indexes
kaway 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 ofk.- Parameters:
h3Address- Origin indexk- Number of rings around the origin- Returns:
- All indexes
kaway 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 ofk.- Parameters:
h3- Origin indexk- Number of rings around the origin- Returns:
- All indexes
kaway from the origin
-
gridDistance
public long gridDistance(java.lang.String a, java.lang.String b)Returns the distance betweenaandb. 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 indexb- Another H3 index- Returns:
- Distance between the two in grid cells
-
gridDistance
public long gridDistance(long a, long b)Returns the distance betweenaandb. 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 indexb- Another H3 index- Returns:
- Distance between the two in grid cells
-
cellToLocalIj
Convertsh3to IJ coordinates in a local coordinate space defined byorigin.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
h3in the local coordinate space.
-
cellToLocalIj
Convertsh3Addressto IJ coordinates in a local coordinate space defined byoriginAddress.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
h3in the local coordinate space.
-
localIjToCell
Converts the IJ coordinates to an index, using a local IJ coordinate space anchored byorigin.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
Converts the IJ coordinates to an index, using a local IJ coordinate space anchored byorigin.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 lineendAddress- 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 lineend- 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 geopolygonholes- Geopolygons of any internal holesres- 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 geopolygonholes- Geopolygon of any internal holesres- 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 geopolygonholes- Geopolygons of any internal holesres- 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 geopolygonholes- Geopolygon of any internal holesres- 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-resis not between 0 and the resolution ofh3, 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 indexchildRes- 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 indexchildRes- 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:
trueif 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:
trueif 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 resolutionres. -
uncompactCells
public java.util.List<java.lang.Long> uncompactCells(java.util.Collection<java.lang.Long> h3, int res)Uncompacts all the given indexes to resolutionres. -
h3ToString
public java.lang.String h3ToString(long h3)Converts fromlongrepresentation of an index toStringrepresentation. -
stringToH3
public long stringToH3(java.lang.String h3Address)Converts fromStringrepresentation of an index tolongrepresentation. -
cellArea
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
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
Return the distance along the sphere between two points.- Parameters:
a- First pointb- Second pointunit- Unit to return the distance in.- Returns:
- Distance from point
ato pointb
-
edgeLength
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
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
Returns the average area inunitfor indexes at resolutionres.- Throws:
java.lang.IllegalArgumentException- Invalid parameter value
-
getHexagonEdgeLengthAvg
Returns the average edge length inunitfor indexes at resolutionres.- Throws:
java.lang.IllegalArgumentException- Invalid parameter value
-
getNumCells
public long getNumCells(int res)Returns the number of unique H3 indexes at resolutionres.- 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)Returnstrueif the two indexes are neighbors. -
areNeighborCells
public boolean areNeighborCells(java.lang.String a, java.lang.String b)Returnstrueif the two indexes are neighbors. -
cellsToDirectedEdge
public long cellsToDirectedEdge(long a, long b)Returns a unidirectional edge index representingatowardsb.- 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 representingatowardsb.- Throws:
java.lang.IllegalArgumentException- The indexes are not neighbors.
-
isValidDirectedEdge
public boolean isValidDirectedEdge(long h3)Returnstrueif the given index is a valid unidirectional edge. -
isValidDirectedEdge
public boolean isValidDirectedEdge(java.lang.String h3)Returnstrueif 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
Returns a list of coordinates representing the given edge. -
directedEdgeToBoundary
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
-
vertexToLatLng
-
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.
-