Skip to content

H3Net Api Cheatsheet

Richard Vasquez edited this page Feb 4, 2021 · 1 revision

H3Net Cheatsheet

I have a fuller idea of what I want the docs to be, but I want to get back to the code, so I'm just going to provide a cheat sheet showing how the regular H3 API is implemented in H3Net

If it turns out that I copied something wrong from the source, or the code operation has changed, submit a PR and I'll do my best to get it approved if it make sense.

Yes, I overloaded ints and decimals. Sorry, not sorry.

h3net entry points to Uber H3 API

GeoToH3

var newH3Index = someGeoBoundary.ToH3Index(int desiredResolution)

H3ToGeo

var newGeoCoord = someH3Index.ToGeoCoord()

H3ToGeoBoundary

var newGeoBoundary = someH3Index.ToGeoBoundary();

MaxKringSize

var maxSize = int someRadiusK.MaxKringSize()

HexRange

(_, List<H3Index> hexRangeCells) = someH3Index.HexRange(k)

HexRangeDistances

List<H3Index> someHexes = someH3Index.HexRangeDistances(k).Item2.Select(i => i.Item1).ToList();

HexRanges

List<H3Index> someHexes = h3Set.HexRanges(k).Item2;

KRing

var cells = someH3Index.KRing(k)

KRingDistances

Dictionary<H3Index, int> = someH3Index.KRingDistances(k)

HexRing

var hexRing = someH3Index.HexRing(k).Item2;

MaxPolyFillSize

int value = someGeoPolygon.MaxPolyFillSize(resolution)

PolyFill

List<H3Index> = someGeoPolygon.Polyfill(resolution)

H3SetToLinkedGeo

someLinkedGeoPolygon = someListH3Index.ToLinkedGeoPolygon()

DegreesToRadians

decimal radians = someDecimal.DegreesToRadians()

RadiansToDegrees

decimal degrees = someDecimal.RadiansToDegrees()

PointDistRads

distance = SomeGeoCoordA.DistanceToRadians(SomeGeoCoordB)

PointDistKm

distance = SomeGeoCoordA.DistanceToKm(SomeGeoCoordB)

PointDitM

distance = SomeGeoCoordA.DistanceToM(SomeGeoCoordB)

HexAreaKm2

someArea = someGeoCoord.HexAreaKm2(resolution)

HexAreaM2

someArea = someGeoCoord.HexAreaM2(resolution)

CellAreaRads2

someArea = someH3Index.CellAreaRadians2()

CellAreaKm2

someArea = someH3Index.CellAreaKm2()

CellAreaM2

someArea = someH3Index.CellAreaM2()

EdgeLengthKm

someLength = GeoCoord.EdgeLengthKm(resolution)

EdgeLengthM

someLength = GeoCoord.EdgeLengthM(resolution)

ExactEdgeLengthRads

exactLength = someDirectedEdge.ExactEdgeLengthRads()

ExactEdgeLengthKm

exactLength = someDirectedEdge.ExactEdgeLengthKm()

ExactEdgeLengthM

exactLength = someDirectedEdge.ExactEdgeLengthM()

NumHexagons

countHexagons = intResolution.NumHexagons()

Res0IndexCount

122

GetRes0Indexes

List<H3Index> = BaseCellsExtensions.GetRes0Indexes()

GetPentagonIndexes

List<H3Index> = intResolution.GetPentagonIndexes()

H3GetResolution

some res = someH3Index.Resolution;

H3GetBaseCell

some baseCell = someH3Index.BaseCell

StringToH3

Use the API. I found the idea to be a bit silly, so I just do a couple TryParse statements to first try to parse the hex string, then parse it as a ulong otherwise return Constants.H3.H3_NULL, an invalid value.

So...

someH3Index = Api.StringToH3(someString s)

H3ToString

someString = someH3Index.ToString()

H3IsValid

return someH3Index.IsValis()

H3ToParent

someParent = someH3Index.ToParent(intResolution)

MaxH3ToChildrenSize

someLong = someH3Index.MaxChildrenSize(intChildResolution)

H3ToChildren

List<H3Index> children = someH3Index.ToChildren(intChildResolution)

H3ToCenterChild

someChild = someH3Index.toCenterChild(intChildResolution)

Compact

List<H3Index> compacted = someList<H3Index>.Compact().Item2;

MaxUncompactSize

someLong = someH3IndexList<H3Index>.MaxUncompactSize(intResolution);

Uncompact

someList<H3Index> = compactedList<H3Index>.Uncompact(intResolution).Item2;

H3IsResClassIii

return someH3Index.IsResClassIii

H3IsPentagon

return someH3Index.IsPentagon

MaxFaceCount

return someH3Index.MaxFaceCount()

H3GetFaces

someList<int> = someH3Index.GetFaces()

H3IndexesAreNeighbors

return someOriginH3Index.IsNeghborTo(someDestinationH3Index)

GetH3UnidirectionalEdge

return someOriginH3Index.UniDirectionalEdgeTo(someDestinationH3Index)

H3UnidirectionalEdgeIsValid

return someHeIndexEdge.IsValidUniEdge()

GetOriginH3IndexFromUnidirectionalEdge

originH3Index = someHeIndexEdge.DestinationFromUniDirectionalEdge()

GetH3IndexesFromUnidirectionalEdge

(H3Index orig, H3Index dest) = someHeIndexEdge.GetH3IndexesFromUniEdge()

GetH3UnidirectionalEdgesFromHexagon

List<H3IndexEdge> = originH3Index.GetUniEdgesFromCell().ToList();

GetH3UnidirectionalEdgeBoundary

someGeoBoundary = someH3IndexEdge.UniEdgeToGeoBoundary();

H3Distance

return originH3Index.DistanceTo(destinationH3Index);

H3LineSize

return startH3Index.LineSize(endH3Index)

H3Line

return startH3Index.LineTo(endH3Index).Item2.ToList();

ExperimentalH3ToLocalIj

return originH3Index.ToLocalIjExperimental(endH3Index3).Item2

ExperimentalLocalIjToH3

return someCoordIj.ToH3Experimental(originH3Index).Item2;

SetGeoDegs

return new GeoCoord().SetDegrees(latDegs, lonDegs)

DestroyLinkedPolygon

someLinkedGeoPolygon.Clear()

DegsToRads

return degrees.DegreesToRadians()

RadsToDegs

return radians.RadiansToDegrees()

Clone this wiki locally