java.lang.Object
org.elasticsearch.h3.H3
Defines the public API of the H3 library.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intmax H3 resolution; H3 version 1 has 16 resolutions, numbered 0 through 15 -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanareNeighborCells(long origin, long destination) returns whether or not the provided hexagons borderstatic booleanareNeighborCells(String origin, String destination) returns whether or not the provided hexagons borderstatic longchildPosToH3(long h3, int childPos) Returns the child cell at the given positionstatic StringchildPosToH3(String h3Address, int childPos) Returns the child address at the given positionstatic longgeoToH3(double lat, double lng, int res) Find the H3 index of the resolutionrescell containing the lat/lon (in degrees)static StringgeoToH3Address(double lat, double lng, int res) Find the H3 index of the resolutionrescell containing the lat/lon (in degrees)static long[]Return all base cellsstatic intgetResolution(long h3) returns the resolution of the provided H3 cellstatic intgetResolution(String h3Address) returns the resolution of the provided H3 cell in string formatstatic String[]Return all base cellsstatic booleanh3IsValid(long h3) Returns true if this is a valid H3 indexstatic booleanReturns true if this is a valid H3 indexstatic 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 inth3ToChildrenSize(long h3) h3ToChildrenSize returns the exact number of childrenstatic longh3ToChildrenSize(long h3, int childRes) h3ToChildrenSize returns the exact number of children for a cell at a given child resolution.static inth3ToChildrenSize(String h3Address) h3ToChildrenSize returns the exact number of childrenstatic longh3ToChildrenSize(String h3Address, int childRes) h3ToChildrenSize returns the exact number of children for a h3 affress at a given child resolution.static CellBoundaryh3ToGeoBoundary(long h3) Find the cellCellBoundarycoordinates for the cellstatic CellBoundaryh3ToGeoBoundary(String h3Address) Find the cellCellBoundarycoordinates for the cellstatic LatLngh3ToLatLng(long h3) Find theLatLngcenter point of the cell.static LatLngh3ToLatLng(String h3Address) Find theLatLngcenter point of the cell.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.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.static inth3ToNotIntersectingChildrenSize(long h3) h3ToNotIntersectingChildrenSize returns the exact number of children intersecting the given parent but not part of the children set.static inth3ToNotIntersectingChildrenSize(String h3Address) h3ToNotIntersectingChildrenSize returns the exact number of children intersecting the given parent but not part of the children set.static longh3ToParent(long h3) Returns the parent of the given index.static Stringh3ToParent(String h3Address) Returns the parent of the given index.static Stringh3ToString(long h3) Converts fromlongrepresentation of an index toStringrepresentation.static long[]hexRing(long h3) Returns the neighbor indexes.static String[]Returns the neighbor indexes.static longhexRingPosToH3(long h3, int ringPos) Returns the neighbor index at the given position.static StringhexRingPosToH3(String h3Address, int ringPos) Returns the neighbor index at the given position.static inthexRingSize(long h3) Returns the number of neighbor indexes.static inthexRingSize(String h3Address) Returns the number of neighbor indexes.static booleanisPentagon(long h3) determines if an H3 cell is a pentagonstatic booleanisPentagon(String h3Address) determines if an H3 cell in string format is a pentagonstatic longnoChildIntersectingPosToH3(long h3, int childPos) Returns the no child intersecting cell at the given positionstatic StringnoChildIntersectingPosToH3(String h3Address, int childPos) Returns the no child intersecting cell at the given positionstatic longnorthPolarH3(int res) Find the h3 index containing the North Pole at the given resolution.static StringnorthPolarH3Address(int res) Find the h3 address containing the North Pole at the given resolution.static longsouthPolarH3(int res) Find the h3 index containing the South Pole at the given resolution.static StringsouthPolarH3Address(int res) Find the h3 address containing the South Pole at the given resolution.static longstringToH3(String h3Address) Converts fromStringrepresentation of an index tolongrepresentation.
-
Field Details
-
MAX_H3_RES
public static final int MAX_H3_RESmax H3 resolution; H3 version 1 has 16 resolutions, numbered 0 through 15- See Also:
-
-
Constructor Details
-
H3
public H3()
-
-
Method Details
-
h3ToString
Converts fromlongrepresentation of an index toStringrepresentation. -
stringToH3
Converts fromStringrepresentation of an index tolongrepresentation. -
getResolution
public static int getResolution(long h3) returns the resolution of the provided H3 cell -
getResolution
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
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
Returns true if this is a valid H3 index -
getLongRes0Cells
public static long[] getLongRes0Cells()Return all base cells -
getStringRes0Cells
Return all base cells -
h3ToLatLng
Find theLatLngcenter point of the cell. -
h3ToLatLng
Find theLatLngcenter point of the cell. -
h3ToGeoBoundary
Find the cellCellBoundarycoordinates for the cell -
h3ToGeoBoundary
Find the cellCellBoundarycoordinates for the cell -
geoToH3
public static long geoToH3(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.
- Throws:
IllegalArgumentException- latitude, longitude, or resolution are out of range.
-
geoToH3Address
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.
- 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
Returns the parent of the given index. -
h3ToChildren
public static long[] h3ToChildren(long h3) Returns the children of the given index. -
h3ToChildren
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
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
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
Returns the no child intersecting cell at the given position -
hexRing
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
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 indexringPos- position of the neighbour index- Returns:
- the actual neighbour at the given position
-
hexRingPosToH3
Returns the neighbor index at the given position.- Parameters:
h3Address- Origin indexringPos- position of the neighbour index- Returns:
- the actual neighbour at the given position
-
areNeighborCells
returns whether or not the provided hexagons border- Parameters:
origin- the first indexdestination- 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 indexdestination- 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 ofchildRes- The child resolution you're interested in- Returns:
- long Exact number of children (handles hexagons and pentagons correctly)
-
h3ToChildrenSize
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 ofchildRes- 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
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
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
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
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.
-