-
Notifications
You must be signed in to change notification settings - Fork 11
H3Net Api 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.
var newH3Index = someGeoBoundary.ToH3Index(int desiredResolution)
var newGeoCoord = someH3Index.ToGeoCoord()
var newGeoBoundary = someH3Index.ToGeoBoundary();
var maxSize = int someRadiusK.MaxKringSize()
(_, List<H3Index> hexRangeCells) = someH3Index.HexRange(k)
List<H3Index> someHexes = someH3Index.HexRangeDistances(k).Item2.Select(i => i.Item1).ToList();
List<H3Index> someHexes = h3Set.HexRanges(k).Item2;
var cells = someH3Index.KRing(k)
Dictionary<H3Index, int> = someH3Index.KRingDistances(k)
var hexRing = someH3Index.HexRing(k).Item2;
int value = someGeoPolygon.MaxPolyFillSize(resolution)
List<H3Index> = someGeoPolygon.Polyfill(resolution)
someLinkedGeoPolygon = someListH3Index.ToLinkedGeoPolygon()
decimal radians = someDecimal.DegreesToRadians()
decimal degrees = someDecimal.RadiansToDegrees()
distance = SomeGeoCoordA.DistanceToRadians(SomeGeoCoordB)
distance = SomeGeoCoordA.DistanceToKm(SomeGeoCoordB)
distance = SomeGeoCoordA.DistanceToM(SomeGeoCoordB)
someArea = someGeoCoord.HexAreaKm2(resolution)
someArea = someGeoCoord.HexAreaM2(resolution)
someArea = someH3Index.CellAreaRadians2()
someArea = someH3Index.CellAreaKm2()
someArea = someH3Index.CellAreaM2()
someLength = GeoCoord.EdgeLengthKm(resolution)
someLength = GeoCoord.EdgeLengthM(resolution)
exactLength = someDirectedEdge.ExactEdgeLengthRads()
exactLength = someDirectedEdge.ExactEdgeLengthKm()
exactLength = someDirectedEdge.ExactEdgeLengthM()
countHexagons = intResolution.NumHexagons()
122
List<H3Index> = BaseCellsExtensions.GetRes0Indexes()
List<H3Index> = intResolution.GetPentagonIndexes()
some res = someH3Index.Resolution;
some baseCell = someH3Index.BaseCell
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)
someString = someH3Index.ToString()
return someH3Index.IsValis()
someParent = someH3Index.ToParent(intResolution)
someLong = someH3Index.MaxChildrenSize(intChildResolution)
List<H3Index> children = someH3Index.ToChildren(intChildResolution)
someChild = someH3Index.toCenterChild(intChildResolution)
List<H3Index> compacted = someList<H3Index>.Compact().Item2;
someLong = someH3IndexList<H3Index>.MaxUncompactSize(intResolution);
someList<H3Index> = compactedList<H3Index>.Uncompact(intResolution).Item2;
return someH3Index.IsResClassIii
return someH3Index.IsPentagon
return someH3Index.MaxFaceCount()
someList<int> = someH3Index.GetFaces()
return someOriginH3Index.IsNeghborTo(someDestinationH3Index)
return someOriginH3Index.UniDirectionalEdgeTo(someDestinationH3Index)
return someHeIndexEdge.IsValidUniEdge()
originH3Index = someHeIndexEdge.DestinationFromUniDirectionalEdge()
(H3Index orig, H3Index dest) = someHeIndexEdge.GetH3IndexesFromUniEdge()
List<H3IndexEdge> = originH3Index.GetUniEdgesFromCell().ToList();
someGeoBoundary = someH3IndexEdge.UniEdgeToGeoBoundary();
return originH3Index.DistanceTo(destinationH3Index);
return startH3Index.LineSize(endH3Index)
return startH3Index.LineTo(endH3Index).Item2.ToList();
return originH3Index.ToLocalIjExperimental(endH3Index3).Item2
return someCoordIj.ToH3Experimental(originH3Index).Item2;
return new GeoCoord().SetDegrees(latDegs, lonDegs)
someLinkedGeoPolygon.Clear()
return degrees.DegreesToRadians()
return radians.RadiansToDegrees()