public class H3Core extends Object
This class is thread safe and can be used as a singleton.
| Modifier and Type | Method and Description |
|---|---|
List<Long> |
compact(Collection<Long> h3)
Returns a compacted set of indexes, at possibly coarser resolutions.
|
List<String> |
compactAddress(Collection<String> h3Addresses)
Returns a compacted set of indexes, at possibly coarser resolutions.
|
double |
edgeLength(int res,
LengthUnit unit)
Returns the average edge length in
unit for indexes at resolution res. |
CoordIJ |
experimentalH3ToLocalIj(long origin,
long h3)
Converts
h3 to IJ coordinates in a local coordinate space defined by
origin. |
CoordIJ |
experimentalH3ToLocalIj(String originAddress,
String h3Address)
Converts
h3Address to IJ coordinates in a local coordinate space defined by
originAddress. |
long |
experimentalLocalIjToH3(long origin,
CoordIJ ij)
Converts the IJ coordinates to an index, using a local IJ coordinate space anchored by
origin. |
String |
experimentalLocalIjToH3(String originAddress,
CoordIJ ij)
Converts the IJ coordinates to an index, using a local IJ coordinate space anchored by
origin. |
long |
geoToH3(double lat,
double lng,
int res)
Find the H3 index of the resolution
res cell containing the lat/lon (in degrees) |
String |
geoToH3Address(double lat,
double lng,
int res)
Find the H3 index of the resolution
res cell containing the lat/lon (in degrees) |
long |
getDestinationH3IndexFromUnidirectionalEdge(long h3)
Returns the destination index of the given unidirectional edge.
|
String |
getDestinationH3IndexFromUnidirectionalEdge(String h3)
Returns the destination index of the given unidirectional edge.
|
List<Long> |
getH3IndexesFromUnidirectionalEdge(long h3)
Returns the origin and destination indexes (in that order) of the given
unidirectional edge.
|
List<String> |
getH3IndexesFromUnidirectionalEdge(String h3)
Returns the origin and destination indexes (in that order) of the given
unidirectional edge.
|
long |
getH3UnidirectionalEdge(long a,
long b)
Returns a unidirectional edge index representing
a towards b. |
String |
getH3UnidirectionalEdge(String a,
String b)
Returns a unidirectional edge index representing
a towards b. |
List<GeoCoord> |
getH3UnidirectionalEdgeBoundary(long h3)
Returns a list of coordinates representing the given edge.
|
List<GeoCoord> |
getH3UnidirectionalEdgeBoundary(String h3)
Returns a list of coordinates representing the given edge.
|
List<Long> |
getH3UnidirectionalEdgesFromHexagon(long h3)
Returns all unidirectional edges originating from the given index.
|
List<String> |
getH3UnidirectionalEdgesFromHexagon(String h3)
Returns all unidirectional edges originating from the given index.
|
long |
getOriginH3IndexFromUnidirectionalEdge(long h3)
Returns the origin index of the given unidirectional edge.
|
String |
getOriginH3IndexFromUnidirectionalEdge(String h3)
Returns the origin index of the given unidirectional edge.
|
Collection<Long> |
getPentagonIndexes(int res)
Returns a collection of all topologically pentagonal cells at the given resolution.
|
Collection<String> |
getPentagonIndexesAddresses(int res)
Returns a collection of all topologically pentagonal cells at the given resolution.
|
Collection<Long> |
getRes0Indexes()
Returns a collection of all base cells (H3 indexes are resolution 0).
|
Collection<String> |
getRes0IndexesAddresses()
Returns a collection of all base cells (H3 indexes are resolution 0).
|
List<List<List<GeoCoord>>> |
h3AddressSetToMultiPolygon(Collection<String> h3Addresses,
boolean geoJson)
Create polygons from a set of contiguous indexes
|
int |
h3Distance(long a,
long b)
Returns the distance between
a and b. |
int |
h3Distance(String a,
String b)
Returns the distance between
a and b. |
int |
h3GetBaseCell(long h3)
Returns the base cell number for this index.
|
int |
h3GetBaseCell(String h3Address)
Returns the base cell number for this index.
|
Collection<Integer> |
h3GetFaces(long h3)
Find all icosahedron faces intersected by a given H3 index, represented
as integers from 0-19.
|
Collection<Integer> |
h3GetFaces(String h3)
Find all icosahedron faces intersected by a given H3 index, represented
as integers from 0-19.
|
int |
h3GetResolution(long h3)
Returns the resolution of the provided index
|
int |
h3GetResolution(String h3Address)
Returns the resolution of the provided index
|
boolean |
h3IndexesAreNeighbors(long a,
long b)
Returns
true if the two indexes are neighbors. |
boolean |
h3IndexesAreNeighbors(String a,
String b)
Returns
true if the two indexes are neighbors. |
boolean |
h3IsPentagon(long h3)
Returns
true if this index is one of twelve pentagons per resolution. |
boolean |
h3IsPentagon(String h3Address)
Returns
true if this index is one of twelve pentagons per resolution. |
boolean |
h3IsResClassIII(long h3)
Determines if an index is Class III or Class II.
|
boolean |
h3IsResClassIII(String h3Address)
Determines if an index is Class III or Class II.
|
boolean |
h3IsValid(long h3)
Returns true if this is a valid H3 index.
|
boolean |
h3IsValid(String h3Address)
Returns true if this is a valid H3 index.
|
List<Long> |
h3Line(long start,
long end)
Given two H3 indexes, return the line of indexes between them (inclusive
of endpoints).
|
List<String> |
h3Line(String startAddress,
String endAddress)
Given two H3 indexes, return the line of indexes between them (inclusive
of endpoints).
|
List<List<List<GeoCoord>>> |
h3SetToMultiPolygon(Collection<Long> h3,
boolean geoJson)
Create polygons from a set of contiguous indexes
|
long |
h3ToCenterChild(long h3,
int childRes)
Returns the center child at the given resolution.
|
String |
h3ToCenterChild(String h3,
int childRes)
Returns the center child at the given resolution.
|
List<Long> |
h3ToChildren(long h3,
int childRes)
Provides the children of the index at the given resolution.
|
List<String> |
h3ToChildren(String h3Address,
int childRes)
Provides the children of the index at the given resolution.
|
GeoCoord |
h3ToGeo(long h3)
Find the latitude, longitude (both in degrees) center point of the cell.
|
GeoCoord |
h3ToGeo(String h3Address)
Find the latitude, longitude (degrees) center point of the cell.
|
List<GeoCoord> |
h3ToGeoBoundary(long h3)
Find the cell boundary in latitude, longitude (degrees) coordinates for the cell
|
List<GeoCoord> |
h3ToGeoBoundary(String h3Address)
Find the cell boundary in latitude, longitude (degrees) coordinates for the cell
|
long |
h3ToParent(long h3,
int res)
Returns the parent of the index at the given resolution.
|
String |
h3ToParentAddress(String h3Address,
int res)
Returns the parent of the index at the given resolution.
|
String |
h3ToString(long h3)
Converts from
long representation of an index to String representation. |
boolean |
h3UnidirectionalEdgeIsValid(long h3)
Returns
true if the given index is a valid unidirectional edge. |
boolean |
h3UnidirectionalEdgeIsValid(String h3)
Returns
true if the given index is a valid unidirectional edge. |
double |
hexArea(int res,
AreaUnit unit)
Returns the average area in
unit for indexes at resolution res. |
List<List<Long>> |
hexRange(long h3,
int k)
Returns in order neighbor traversal.
|
List<List<String>> |
hexRange(String h3Address,
int k)
Returns in order neighbor traversal.
|
List<Long> |
hexRing(long h3,
int k)
Returns in order neighbor traversal, of indexes with distance of
k. |
List<String> |
hexRing(String h3Address,
int k)
Returns in order neighbor traversal, of indexes with distance of
k. |
List<Long> |
kRing(long h3,
int k)
Neighboring indexes in all directions.
|
List<String> |
kRing(String h3Address,
int k)
Neighboring indexes in all directions.
|
List<List<Long>> |
kRingDistances(long h3,
int k)
Neighboring indexes in all directions, ordered by distance from the origin index.
|
List<List<String>> |
kRingDistances(String h3Address,
int k)
Neighboring indexes in all directions, ordered by distance from the origin index.
|
List<List<String>> |
kRings(String h3Address,
int k)
Neighboring indexes in all directions.
|
static H3Core |
newInstance()
Create by unpacking the H3 native library to disk and loading it.
|
static H3Core |
newInstance(H3CoreLoader.OperatingSystem os,
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.
|
long |
numHexagons(int res)
Returns the number of unique H3 indexes at resolution
res. |
List<Long> |
polyfill(List<GeoCoord> points,
List<List<GeoCoord>> holes,
int res)
Finds indexes within the given geofence.
|
List<String> |
polyfillAddress(List<GeoCoord> points,
List<List<GeoCoord>> holes,
int res)
Finds indexes within the given geofence.
|
long |
stringToH3(String h3Address)
Converts from
String representation of an index to long representation. |
List<Long> |
uncompact(Collection<Long> h3,
int res)
Uncompacts all the given indexes to resolution
res. |
List<String> |
uncompactAddress(Collection<String> h3Addresses,
int res)
Uncompacts all the given indexes to resolution
res. |
public static H3Core newInstance() throws IOException
SecurityException - Loading the library was not allowed by the
SecurityManager.UnsatisfiedLinkError - The library could not be loadedIOException - The library could not be extracted to disk.public static H3Core newInstance(H3CoreLoader.OperatingSystem os, String arch) throws IOException
SecurityException - Loading the library was not allowed by the
SecurityManager.UnsatisfiedLinkError - The library could not be loadedIOException - The library could not be extracted to disk.public static H3Core newSystemInstance()
SecurityException - The library could not be loadedUnsatisfiedLinkError - The library could not be loadedpublic boolean h3IsValid(long h3)
public boolean h3IsValid(String h3Address)
public int h3GetBaseCell(long h3)
public int h3GetBaseCell(String h3Address)
public boolean h3IsPentagon(long h3)
true if this index is one of twelve pentagons per resolution.public boolean h3IsPentagon(String h3Address)
true if this index is one of twelve pentagons per resolution.public long geoToH3(double lat,
double lng,
int res)
res cell containing the lat/lon (in degrees)lat - Latitude in degrees.lng - Longitude in degrees.res - Resolution, 0 <= res <= 15IllegalArgumentException - latitude, longitude, or resolution are out of range.public String geoToH3Address(double lat, double lng, int res)
res cell containing the lat/lon (in degrees)lat - Latitude in degrees.lng - Longitude in degrees.res - Resolution, 0 <= res <= 15IllegalArgumentException - Latitude, longitude, or resolution is out of range.public GeoCoord h3ToGeo(long h3)
public GeoCoord h3ToGeo(String h3Address)
public List<GeoCoord> h3ToGeoBoundary(long h3)
public List<GeoCoord> h3ToGeoBoundary(String h3Address)
public List<String> kRing(String h3Address, int k)
h3Address - Origin indexk - Number of rings around the originpublic List<List<String>> kRings(String h3Address, int k)
h3Address - Origin indexk - Number of rings around the originkRing(String, int) results.public List<Long> kRing(long h3, int k)
h3 - Origin indexk - Number of rings around the originpublic List<List<String>> kRingDistances(String h3Address, int k)
h3Address - Origin indexk - Number of rings around the originpublic List<List<Long>> kRingDistances(long h3, int k)
h3 - Origin indexk - Number of rings around the originpublic List<List<String>> hexRange(String h3Address, int k) throws PentagonEncounteredException
h3Address - Origin hexagon indexk - Number of rings around the originPentagonEncounteredException - A pentagon was encountered while iterating the ringspublic List<List<Long>> hexRange(long h3, int k) throws PentagonEncounteredException
h3 - Origin hexagon indexk - Number of rings around the originPentagonEncounteredException - A pentagon was encountered while iterating the ringspublic List<String> hexRing(String h3Address, int k) throws PentagonEncounteredException
k.h3Address - Origin indexk - Number of rings around the origink away from the originPentagonEncounteredException - A pentagon or pentagonal distortion was encountered.public List<Long> hexRing(long h3, int k) throws PentagonEncounteredException
k.h3 - Origin indexk - Number of rings around the origink away from the originPentagonEncounteredException - A pentagon or pentagonal distortion was encountered.public int h3Distance(String a, String b) throws DistanceUndefinedException
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:
a - An H3 indexb - Another H3 indexDistanceUndefinedException - H3 cannot compute the distance.public int h3Distance(long a,
long b)
throws DistanceUndefinedException
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:
a - An H3 indexb - Another H3 indexDistanceUndefinedException - H3 cannot compute the distance.public CoordIJ experimentalH3ToLocalIj(long origin, long h3) throws PentagonEncounteredException, LocalIjUndefinedException
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.
origin - Anchoring index for the local coordinate space.h3 - Index to find the coordinates of.h3 in the local coordinate space.IllegalArgumentException - The two indexes are not comparable.PentagonEncounteredException - The two indexes are separated by pentagonal distortion.LocalIjUndefinedException - The two indexes are too far apart.public CoordIJ experimentalH3ToLocalIj(String originAddress, String h3Address) throws PentagonEncounteredException, LocalIjUndefinedException
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.
originAddress - Anchoring index for the local coordinate space.h3Address - Index to find the coordinates of.h3 in the local coordinate space.IllegalArgumentException - The two indexes are not comparable.PentagonEncounteredException - The two indexes are separated by pentagonal distortion.LocalIjUndefinedException - The two indexes are too far apart.public long experimentalLocalIjToH3(long origin,
CoordIJ ij)
throws LocalIjUndefinedException
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.
origin - Anchoring index for the local coordinate space.ij - Coordinates in the local IJ coordinate space.ijLocalIjUndefinedException - No index is defined at the given location, for example
because the coordinates are too far away from the origin, or pentagon distortion is encountered.public String experimentalLocalIjToH3(String originAddress, CoordIJ ij) throws LocalIjUndefinedException
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.
originAddress - Anchoring index for the local coordinate space.ij - Coordinates in the local IJ coordinate space.ijLocalIjUndefinedException - No index is defined at the given location, for example
because the coordinates are too far away from the origin, or pentagon distortion is encountered.public List<String> h3Line(String startAddress, String endAddress) throws LineUndefinedException
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:
startAddress - Start index of the lineendAddress - End index of the lineLineUndefinedException - The line could not be computed.public List<Long> h3Line(long start, long end) throws LineUndefinedException
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:
start - Start index of the lineend - End index of the lineLineUndefinedException - The line could not be computed.public List<String> polyfillAddress(List<GeoCoord> points, List<List<GeoCoord>> holes, int res)
points - Outline geofenceholes - Geofences of any internal holesres - Resolution of the desired indexespublic List<Long> polyfill(List<GeoCoord> points, List<List<GeoCoord>> holes, int res)
points - Outline geofenceholes - Geofences of any internal holesres - Resolution of the desired indexesIllegalArgumentException - Invalid resolutionpublic List<List<List<GeoCoord>>> h3AddressSetToMultiPolygon(Collection<String> h3Addresses, boolean geoJson)
public List<List<List<GeoCoord>>> h3SetToMultiPolygon(Collection<Long> h3, boolean geoJson)
public int h3GetResolution(String h3Address)
public int h3GetResolution(long h3)
public long h3ToParent(long h3,
int res)
h3 - H3 index.res - Resolution of the parent, 0 <= res <= h3GetResolution(h3)IllegalArgumentException - res is not between 0 and the resolution of h3, inclusive.public String h3ToParentAddress(String h3Address, int res)
h3Address - H3 index.res - Resolution of the parent, 0 <= res <= h3GetResolution(h3)public List<String> h3ToChildren(String h3Address, int childRes)
childRes - Resolution of the childrenpublic List<Long> h3ToChildren(long h3, int childRes)
h3 - H3 index.childRes - Resolution of the childrenIllegalArgumentException - Invalid resolutionpublic String h3ToCenterChild(String h3, int childRes)
h3 - Parent H3 indexchildRes - Resolution of the childIllegalArgumentException - Invalid resolution (e.g. coarser than the parent)public long h3ToCenterChild(long h3,
int childRes)
h3 - Parent H3 indexchildRes - Resolution of the childIllegalArgumentException - Invalid resolution (e.g. coarser than the parent)public boolean h3IsResClassIII(String h3Address)
true if the index is Class IIIpublic boolean h3IsResClassIII(long h3)
h3 - H3 index.true if the index is Class IIIpublic List<String> compactAddress(Collection<String> h3Addresses)
public List<Long> compact(Collection<Long> h3)
IllegalArgumentException - Invalid input, such as duplicated indexes.public List<String> uncompactAddress(Collection<String> h3Addresses, int res)
res.public List<Long> uncompact(Collection<Long> h3, int res)
res.IllegalArgumentException - Invalid input, such as indexes finer than res.public String h3ToString(long h3)
long representation of an index to String representation.public long stringToH3(String h3Address)
String representation of an index to long representation.public double hexArea(int res,
AreaUnit unit)
unit for indexes at resolution res.IllegalArgumentException - Invalid parameter valuepublic double edgeLength(int res,
LengthUnit unit)
unit for indexes at resolution res.IllegalArgumentException - Invalid parameter valuepublic long numHexagons(int res)
res.IllegalArgumentException - Invalid resolutionpublic Collection<String> getRes0IndexesAddresses()
public Collection<Long> getRes0Indexes()
public Collection<String> getPentagonIndexesAddresses(int res)
IllegalArgumentException - Invalid resolution.public Collection<Long> getPentagonIndexes(int res)
IllegalArgumentException - Invalid resolution.public boolean h3IndexesAreNeighbors(long a,
long b)
true if the two indexes are neighbors.public boolean h3IndexesAreNeighbors(String a, String b)
true if the two indexes are neighbors.public long getH3UnidirectionalEdge(long a,
long b)
a towards b.IllegalArgumentException - The indexes are not neighbors.public String getH3UnidirectionalEdge(String a, String b)
a towards b.IllegalArgumentException - The indexes are not neighbors.public boolean h3UnidirectionalEdgeIsValid(long h3)
true if the given index is a valid unidirectional edge.public boolean h3UnidirectionalEdgeIsValid(String h3)
true if the given index is a valid unidirectional edge.public long getOriginH3IndexFromUnidirectionalEdge(long h3)
public String getOriginH3IndexFromUnidirectionalEdge(String h3)
public long getDestinationH3IndexFromUnidirectionalEdge(long h3)
public String getDestinationH3IndexFromUnidirectionalEdge(String h3)
public List<Long> getH3IndexesFromUnidirectionalEdge(long h3)
public List<String> getH3IndexesFromUnidirectionalEdge(String h3)
public List<Long> getH3UnidirectionalEdgesFromHexagon(long h3)
public List<String> getH3UnidirectionalEdgesFromHexagon(String h3)
public List<GeoCoord> getH3UnidirectionalEdgeBoundary(long h3)
public List<GeoCoord> getH3UnidirectionalEdgeBoundary(String h3)
public Collection<Integer> h3GetFaces(String h3)
h3 - Index to find icosahedron faces for.public Collection<Integer> h3GetFaces(long h3)
h3 - Index to find icosahedron faces for.Copyright © 2019 Uber Open Source. All rights reserved.